Documentation
¶
Index ¶
- func Close()
- func OnCreateFeed(f func(CreatedFeedMessage)) error
- func PublishCreatedFeed(ctx context.Context, feed *models.Feed) error
- func SetEventStore(store EventStore)
- func SubscribeCreatedFeed(ctx context.Context) (<-chan CreatedFeedMessage, error)
- type CreatedFeedMessage
- type EventStore
- type Message
- type NatsEventStore
- func (n *NatsEventStore) Close()
- func (n *NatsEventStore) OnCreateFeed(f func(CreatedFeedMessage)) (err error)
- func (n *NatsEventStore) PublishCreatedFeed(ctx context.Context, feed *models.Feed) error
- func (n *NatsEventStore) SubscribeCreatedFeed(ctx context.Context) (<-chan CreatedFeedMessage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnCreateFeed ¶
func OnCreateFeed(f func(CreatedFeedMessage)) error
func SetEventStore ¶
func SetEventStore(store EventStore)
func SubscribeCreatedFeed ¶
func SubscribeCreatedFeed(ctx context.Context) (<-chan CreatedFeedMessage, error)
Types ¶
type CreatedFeedMessage ¶
type CreatedFeedMessage struct { Id string `json:"id"` Title string `json:"title"` Description string `json:"description"` CreatedAt time.Time `json:"created_at"` }
Struct that will be transmitted through the NATS system
func (CreatedFeedMessage) Type ¶
func (m CreatedFeedMessage) Type() string
Message to Event Feed Created
type EventStore ¶
type EventStore interface { Close() // Publish new feed event PublishCreatedFeed(ctx context.Context, feed *models.Feed) error // Subscribe to feed event SubscribeCreatedFeed(ctx context.Context) (<-chan CreatedFeedMessage, error) // Callback when new feed is created OnCreateFeed(f func(CreatedFeedMessage)) error }
Abstract implementation of NATS
type Message ¶
type Message interface {
Type() string
}
Dependency inversion interface Abstract implementation
type NatsEventStore ¶
type NatsEventStore struct {
// contains filtered or unexported fields
}
func NewNats ¶
func NewNats(url string) (*NatsEventStore, error)
Methods of NatsEventStore Constructor
func (*NatsEventStore) OnCreateFeed ¶
func (n *NatsEventStore) OnCreateFeed(f func(CreatedFeedMessage)) (err error)
Closure to subscribe
func (*NatsEventStore) PublishCreatedFeed ¶
Method Publish Created Feed to services connected to NATS
func (*NatsEventStore) SubscribeCreatedFeed ¶
func (n *NatsEventStore) SubscribeCreatedFeed(ctx context.Context) (<-chan CreatedFeedMessage, error)
Subscription Channel
Click to show internal directories.
Click to hide internal directories.