Documentation ¶
Index ¶
- Constants
- Variables
- type Kind
- type Option
- type Processor
- type RequestProcessor
- type Server
- func (ns *Server) AddProcessor(name string, kind Kind, subject string, processor Processor, replace bool) error
- func (ns *Server) AddRequestProcessor(name string, subject string, processor RequestProcessor, replace bool) error
- func (ns *Server) Publish(subject string, kind Kind, message []byte, options ...Option) error
- func (ns *Server) RequestSync(subject string, message []byte, timeout time.Duration, options ...Option) (resp []byte, err error)
- func (ns *Server) SetLogger(logger *zap.Logger)
- func (ns *Server) Stop()
Constants ¶
View Source
const ( ConfigURL = "url" ConfigPrefix = "prefix" )
Variables ¶
View Source
var ( // ErrDuplicateProcessor - processor already exists ErrDuplicateProcessor = errors.New("processor is duplicate") ErrNotConnected = errors.New("nats: not connected") )
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind string
Kind - kind of notification
const ( // KindInfo - informational message KindInfo Kind = "inf" // KindError - error KindError Kind = "err" // KindRequest - request of some kind KindRequest Kind = "req" // KindSystem - system message KindSystem Kind = "sys" // KindEvent - some event in the system KindEvent Kind = "evn" // KindUnknown may be used in case if kind is not in the list KindUnknown Kind = "unknown" // KindAbsolut should be used if prefix should not be added KindAbsolut Kind = "abs" )
describes possible kinds
type Processor ¶
type Processor interface { // ProcessNatsMessage is called on incoming message ProcessNatsMessage(subject string, msg []byte) error }
Processor is interface for processor of incoming messages
type RequestProcessor ¶
type RequestProcessor interface {
ProcessNatsRequest(topic string, request []byte) (response []byte, err error)
}
RequestProcessor is interface for processor of incoming requests
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wrapper around NATS server
func (*Server) AddProcessor ¶
func (ns *Server) AddProcessor(name string, kind Kind, subject string, processor Processor, replace bool) error
AddProcessor adds the incoming messages processor
func (*Server) AddRequestProcessor ¶
func (ns *Server) AddRequestProcessor(name string, subject string, processor RequestProcessor, replace bool) error
AddRequestProcessor adds the incoming request processor
func (*Server) RequestSync ¶
Click to show internal directories.
Click to hide internal directories.