Documentation ¶
Index ¶
- Variables
- func Close() error
- func Listen(ctx context.Context) error
- func OnClose() <-chan bool
- func Publish(ctx context.Context, name string, messages ...any) error
- func Register(params ...any) error
- func Subscribe(ctx context.Context, name string, receiver any) error
- type ErrorHandler
- type FuncPublisher
- type FuncReceiver
- type Message
- type ModelSubscriber
- type MultiPublisher
- type PanicHandler
- type Publisher
- type Receiver
- type Registry
- func (r *Registry) Close() error
- func (r *Registry) Listen(ctx context.Context) (err error)
- func (r *Registry) OnClose() <-chan bool
- func (r *Registry) Publish(ctx context.Context, name string, messages ...any) error
- func (r *Registry) Publisher(name string) Publisher
- func (r *Registry) Register(params ...any) error
- func (r *Registry) Subscribe(ctx context.Context, name string, receiver any) error
- func (r *Registry) Subscriber(name string) Subscriber
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRegisterParameter = errors.New(`invalid register parameter`) ErrUndefinedPublisherInterface = errors.New(`undefined publisher interface`) ErrUndefinedSubscriberInterface = errors.New(`undefined subscriber interface`) ErrInterfaceAlreadySubscribed = errors.New("[notificationcenter] interface already subscribed") )
Error list...
var DefaultRegistry = NewRegistry()
DefaultRegistry is global registry
Functions ¶
func OnClose ¶
func OnClose() <-chan bool
OnClose event will be executed only after closing all interfaces
Usecases in the application makes subsribing for the finishing event very convinient ¶
```go
func myDatabaseObserver() { <- notificationcenter.OnClose() // ... Do something }
```
Types ¶
type ErrorHandler ¶
ErrorHandler type to process error value
type FuncPublisher ¶
FuncPublisher provides custom function wrapper for the custom publisher processor
type FuncReceiver ¶
FuncReceiver implements Receiver interface for a single function
func (FuncReceiver) Receive ¶
func (f FuncReceiver) Receive(msg Message) error
Receive message from sub-service to process it with function
type Message ¶
type Message interface { // Context of the message Context() context.Context // Unical message ID (depends on transport) ID() string // Body returns message data as bytes Body() []byte // Acknowledgment of the message processing Ack() error }
Message describes the access methods to the message original object
type ModelSubscriber ¶
type ModelSubscriber struct { // Error handler pointer ErrorHandler ErrorHandler // Panic handler pointer PanicHandler PanicHandler // contains filtered or unexported fields }
ModelSubscriber provedes subscibe functionality implementation
func (*ModelSubscriber) Close ¶
func (s *ModelSubscriber) Close() error
Close all receivers if supports io.Closer interface
func (*ModelSubscriber) ProcessMessage ¶
func (s *ModelSubscriber) ProcessMessage(msg Message) error
ProcessMessage by all receivers
type PanicHandler ¶
PanicHandler type to process panic action
type Publisher ¶
type Publisher interface { // Publish one or more messages to the pub-service Publish(ctx context.Context, messages ...any) error }
Publisher pipeline base declaration
func PublisherByName ¶
PublisherByName returns pub interface by name if exists or Nil otherwise
type Receiver ¶
Receiver describe interface of message processing
func ExtFuncReceiver ¶
ExtFuncReceiver wraps function argument with arbitrary input data type
func ReceiverFrom ¶
ReceiverFrom converts income handler type to Receiver interface
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry provides functionality of access to pub/sub interfaces by string names.
func (*Registry) OnClose ¶
OnClose event will be executed only after closing all interfaces
Usecases in the application makes subsribing for the finishing event very convinient ¶
```go
func myDatabaseObserver() { <- notificationcenter.OnClose() // ... Do something }
```
func (*Registry) Register ¶
Register one or more Publisher or Subscriber services. As input parameters must be order of parameters {Name, interface}
Example: ```
nc.Register( "events", kafka.MustNewSubscriber(), "notifications", nats.MustNewSubscriber(), )
```
func (*Registry) Subscriber ¶
func (r *Registry) Subscriber(name string) Subscriber
Subscriber returns sub interface by name if exists or Nil otherwise
type Subscriber ¶
type Subscriber interface { io.Closer // Subscribe new receiver to receive messages from the subsribtion Subscribe(ctx context.Context, receiver Receiver) error // Start processing queue Listen(ctx context.Context) error }
Subscriber provides methods of working with subscription
func SubscriberByName ¶
func SubscriberByName(name string) Subscriber
SubscriberByName returns sub interface by name if exists or Nil otherwise
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package pg provides posibility to subscribe to internal postgres events.
|
Package pg provides posibility to subscribe to internal postgres events. |
wrappers
|
|