Documentation ¶
Overview ¶
Package messaging provide functionality to implement message queue system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KafkaPublisher ¶
type KafkaPublisher struct {
// contains filtered or unexported fields
}
KafkaPublisher is responsible to publish message to Kafka.
func NewKafkaPublisher ¶
func NewKafkaPublisher(writer Writer) *KafkaPublisher
NewKafkaPublisher creates an instance of KafkaPublisher.
func (*KafkaPublisher) Publish ¶
func (kp *KafkaPublisher) Publish(ctx context.Context, event *togglev1.ToggleEvent) error
Publish publishes toggle event to Kafka. The event will be converted to JSON.
type KafkaSubscriber ¶
type KafkaSubscriber struct {
// contains filtered or unexported fields
}
KafkaSubscriber is responsible to subscribe message from Kafka.
func NewKafkaSubscriber ¶
func NewKafkaSubscriber(reader Reader) *KafkaSubscriber
NewKafkaSubscriber creates an instance of KafkaSubscriber.
func (*KafkaSubscriber) Subscribe ¶
func (ks *KafkaSubscriber) Subscribe(ctx context.Context, fn func(*togglev1.ToggleEvent) error) error
Subscribe subscribes to a certain topic and process the incoming message using the fn parameter. This method is blocking.
type Reader ¶
Reader defines a little interface for Kafka reader/subscriber functionality. Since in the real implementation we can use kafka.Reader, this interface exists mostly for resting purpose.
type RedisPublisher ¶
type RedisPublisher struct {
// contains filtered or unexported fields
}
RedisPublisher is responsible to publish message to Redis. It uses asynq client.
func NewRedisPublisher ¶
func NewRedisPublisher(cfg *config.Redis) *RedisPublisher
NewRedisPublisher creates an instance of RedisPublisher.
func (*RedisPublisher) Publish ¶
func (rp *RedisPublisher) Publish(ctx context.Context, event *togglev1.ToggleEvent) error
Publish publishes toggle event to Redis. The event will be converted to JSON.
type RedisSubscriber ¶
type RedisSubscriber struct {
// contains filtered or unexported fields
}
RedisSubscriber is responsible to subscribe message from Redis.
func NewRedisSubscriber ¶
func NewRedisSubscriber(cfg *config.Redis) *RedisSubscriber
NewRedisSubscriber creates an instance of RedisSubscriber.
func (*RedisSubscriber) Subscribe ¶
func (rs *RedisSubscriber) Subscribe(ctx context.Context, fn func(*togglev1.ToggleEvent) error) error
Subscribe subscribes to a certain topic and process the incoming message using the fn parameter. This method is blocking.
type Writer ¶
type Writer interface { WriteMessages(ctx context.Context, messages ...kafka.Message) error Close() error }
Writer defines a little interface for Kafka writer/publisher functionality. Since in the real implementation we can use kafka.Writer, this interface exists mostly for testing purpose.