Documentation ¶
Index ¶
- func ClientRequest[REQUEST any, RESPONSE any](subject string, req REQUEST) (RESPONSE, error)
- func Connect(cfg Config) error
- func ConvertData[T any](data []byte) T
- func GetConn() *nats.Conn
- func IsDisconnected()
- func Publish(sub string, payload []byte) error
- func PublishRequest(sub, reply string, data []byte) error
- func QueueSubscribe(subject, queue string, cb nats.MsgHandler)
- func Reply(msg *nats.Msg, payload []byte) error
- func Request(subject string, payload []byte) (*nats.Msg, error)
- func Response(msg *nats.Msg, payload interface{}, message string) error
- func ToBytes(data interface{}) []byte
- type Config
- type MethodHandle
- type NatsResponse
- type QueueDesc
- type ServiceDesc
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientRequest ¶
ClientRequest ...
func IsDisconnected ¶
func IsDisconnected()
func PublishRequest ¶
func QueueSubscribe ¶
func QueueSubscribe(subject, queue string, cb nats.MsgHandler)
QueueSubscribe ...
Types ¶
type Config ¶
type Config struct { // Connect url URL string // Auth user User string // Auth password Password string // TLS config TLS *TLSConfig // RequestTimeout RequestTimeout time.Duration Debug bool }
Config ...
type MethodHandle ¶
type MethodHandle func(queue interface{}) nats.MsgHandler
type NatsResponse ¶
type NatsResponse struct { Success bool `json:"success"` Message string `json:"message"` Data []byte `json:"data"` }
NatsResponse ..
type QueueDesc ¶
type QueueDesc struct { Subject string Worker string Handle MethodHandle }
func (QueueDesc) GetSubject ¶
GetSubject get subject for nats request
type ServiceDesc ¶
type ServiceDesc struct {
Queues []QueueDesc
}
func (ServiceDesc) Register ¶
func (s ServiceDesc) Register(queue interface{}) error
Register callback handler
Click to show internal directories.
Click to hide internal directories.