Documentation ¶
Index ¶
- Constants
- type BatchResult
- type BfPublisher
- type BuffPublisherWithRetry
- func (p *BuffPublisherWithRetry) Close(ctx context.Context) error
- func (p *BuffPublisherWithRetry) Flush(ctx context.Context) error
- func (p *BuffPublisherWithRetry) GetBufferedMessages(topic string) []*messaging.Message
- func (p *BuffPublisherWithRetry) Publish(ctx context.Context, topic string, message messaging.Message) error
- type BufferedPublishResult
- type BufferedPublisher
- type BufferedPublisherWithRetry
- type Client
- type Error
- type ErrorCode
- type PublishResult
- type Topic
- type TopicCache
- type TopicCacheItem
- type TopicPublishConfig
Constants ¶
const ( DefaultInitialRetryInterval = 50 * time.Millisecond DefaultFlushDelayThreshold = time.Millisecond * 10 DefaultMaxRetryCount int16 = 3 DefaultBatchSize int32 = 1000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchResult ¶
type BatchResult struct {
Results []*BufferedPublishResult
}
BatchResult - result from batch publishing. It contains reference Id to the original message published.
type BfPublisher ¶
BfPublisher - BufferedPublisher struct implementation.
func (*BfPublisher) Close ¶
func (p *BfPublisher) Close(ctx context.Context) error
Close - close the BufferedPublisher and all the related goroutines.
func (*BfPublisher) Publish ¶
func (p *BfPublisher) Publish(ctx context.Context, topicName string, payloadBatch []messaging.Message) (*BatchResult, error)
Publish - Publish a Batch of Messages in Json
type BuffPublisherWithRetry ¶
type BuffPublisherWithRetry struct { sync.Mutex TopicCache *TopicCache Done chan struct{} RetryCh chan retryBatch // contains filtered or unexported fields }
BuffPublisherWithRetry - buffered publisher struct implementation.
func (*BuffPublisherWithRetry) Close ¶
func (p *BuffPublisherWithRetry) Close(ctx context.Context) error
Close - close the BufferedPublisher and all the related goroutines.
func (*BuffPublisherWithRetry) Flush ¶
func (p *BuffPublisherWithRetry) Flush(ctx context.Context) error
Flush all the messages for all the topics.
func (*BuffPublisherWithRetry) GetBufferedMessages ¶
func (p *BuffPublisherWithRetry) GetBufferedMessages(topic string) []*messaging.Message
GetBufferedMessages - get hte messages in the buyffer. Useful for testing.
func (*BuffPublisherWithRetry) Publish ¶
func (p *BuffPublisherWithRetry) Publish(ctx context.Context, topic string, message messaging.Message) error
Publish - publish a message in Json format and buffer it in an internal buffer of a given size, before Flushing in batch. The batching mechanism is abstracted from the user that just need to publish one message at time.
type BufferedPublishResult ¶
BufferedPublishResult - published result.
type BufferedPublisher ¶
type BufferedPublisher interface { Publish(ctx context.Context, topicName string, payloadBatch []messaging.Message) (*BatchResult, error) Close(ctx context.Context) error }
BufferedPublisher - interface for the publisher
func NewBufferedPublisher ¶
func NewBufferedPublisher( client Client, publishConfig TopicPublishConfig) (BufferedPublisher, error)
NewBufferedPublisher - Constructor of BufferedPublisher.
type BufferedPublisherWithRetry ¶
type BufferedPublisherWithRetry interface { Publish(ctx context.Context, topic string, message messaging.Message) error Flush(ctx context.Context) error Close(ctx context.Context) error GetBufferedMessages(topic string) []*messaging.Message }
BufferedPublisherWithRetry - interface for the publisher
func NewBufferedPublisherWithRetry ¶
func NewBufferedPublisherWithRetry( ctx context.Context, client Client, publishConfig TopicPublishConfig) (BufferedPublisherWithRetry, error)
NewBufferedPublisherWithRetry - Constructor.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error - General PubSub Error.
func NewMessagingError ¶
NewMessagingError - NewMessagingError constructor.
func NewMessagingErrorCode ¶
NewMessagingErrorCode - MessagingError constructor given a predefined Error Code.
type PublishResult ¶
PublishResult - PubSub Publish Result wrapper interface.
type Topic ¶
type Topic interface { Publish(ctx context.Context, msg messaging.Message) PublishResult Stop() Flush() String() string ConfigPublishSettings(config TopicPublishConfig) }
Topic - Topic wrapper interface.
type TopicCache ¶
type TopicCache struct { sync.Mutex Cache map[string]*TopicCacheItem }
TopicCache - Topic Cache with mutex access.
type TopicCacheItem ¶
type TopicCacheItem struct {
// contains filtered or unexported fields
}
TopicCacheItem - topic cache item.
func NewTopicCacheItem ¶
func NewTopicCacheItem(topic Topic, initialValue int32) *TopicCacheItem
NewTopicCacheItem -