natx

package module
v0.0.0-...-91aa13a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 7 Imported by: 0

README

natx

基于nat的request/reply 封装,每一个request/reply需要实现NatXAPP接口。默认使用msgp编码,其他默认参数可修改。

Documentation

Index

Constants

View Source
const (
	SUBJ_PRE  = "NCSUBJ-"
	QUEUE_PRE = "NCQUE-"
)

默认为subj和queue名称加前缀

View Source
const (
	MSGP_ENCODER = "msgp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultAPP

type DefaultAPP struct {
	// contains filtered or unexported fields
}

func (*DefaultAPP) Publish

func (app *DefaultAPP) Publish(subj string, data interface{}) error

func (*DefaultAPP) QueueSubscribe

func (app *DefaultAPP) QueueSubscribe(subj string, handle Handle) error

func (*DefaultAPP) Request

func (app *DefaultAPP) Request(ctx context.Context, subj string, req interface{}) (interface{}, error)

func (*DefaultAPP) Subscribe

func (app *DefaultAPP) Subscribe(subj string, handle Handle) error

type DefaultAPPReq

type DefaultAPPReq struct {
	Arg1 int
	Arg2 string
}

type DefaultAPPResp

type DefaultAPPResp struct {
	Arg1 int
	Arg2 string
}

type Handle

type Handle func(subj string, req interface{}) interface{}

type MsgpEncoder

type MsgpEncoder struct {
}

func (*MsgpEncoder) Decode

func (ge *MsgpEncoder) Decode(subject string, data []byte, vPtr interface{}) (err error)

Decode

func (*MsgpEncoder) Encode

func (ge *MsgpEncoder) Encode(subject string, v interface{}) ([]byte, error)

Encode

type NATClient

type NATClient struct {
	// contains filtered or unexported fields
}

func NewNATClient

func NewNATClient(endpoints []string) *NATClient

func (*NATClient) Destroy

func (p *NATClient) Destroy()

func (*NATClient) Publish

func (p *NATClient) Publish(subj string, data interface{}) error

func (*NATClient) QueueSubscribe

func (p *NATClient) QueueSubscribe(subj string, handle Handle) error

func (*NATClient) Request

func (p *NATClient) Request(ctx context.Context, subj string, req interface{}, resp interface{}) error

func (*NATClient) Subscribe

func (p *NATClient) Subscribe(subj string, handle Handle) error

type NatXAPP

type NatXAPP interface {
	Request(context.Context, string, interface{}) (interface{}, error)
	Subscribe(string, Handle) error
	QueueSubscribe(string, Handle) error
	Publish(string, interface{}) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL