remove events store
This commit is contained in:
@@ -1,6 +1,33 @@
|
||||
package events
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v3/store"
|
||||
)
|
||||
|
||||
// Options which are used to configure the in-memory stream
|
||||
type Options struct {
|
||||
Store store.Store
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
// Option is a function which configures options
|
||||
type Option func(o *Options)
|
||||
|
||||
// WithStore sets the underlying store to use
|
||||
func WithStore(s store.Store) Option {
|
||||
return func(o *Options) {
|
||||
o.Store = s
|
||||
}
|
||||
}
|
||||
|
||||
// WithTTL sets the default TTL
|
||||
func StreamTTL(ttl time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.TTL = ttl
|
||||
}
|
||||
}
|
||||
|
||||
// PublishOptions contains all the options which can be provided when publishing an event
|
||||
type PublishOptions struct {
|
||||
@@ -27,8 +54,8 @@ func WithTimestamp(t time.Time) PublishOption {
|
||||
}
|
||||
}
|
||||
|
||||
// SubscribeOptions contains all the options which can be provided when subscribing to a topic
|
||||
type SubscribeOptions struct {
|
||||
// ConsumeOptions contains all the options which can be provided when subscribing to a topic
|
||||
type ConsumeOptions struct {
|
||||
// Queue is the name of the subscribers queue, if two subscribers have the same queue the message
|
||||
// should only be published to one of them
|
||||
Queue string
|
||||
@@ -48,42 +75,42 @@ type SubscribeOptions struct {
|
||||
CustomRetries bool
|
||||
}
|
||||
|
||||
// SubscribeOption sets attributes on SubscribeOptions
|
||||
type SubscribeOption func(o *SubscribeOptions)
|
||||
// ConsumeOption sets attributes on ConsumeOptions
|
||||
type ConsumeOption func(o *ConsumeOptions)
|
||||
|
||||
// WithQueue sets the Queue fielf on SubscribeOptions to the value provided
|
||||
func WithQueue(q string) SubscribeOption {
|
||||
return func(o *SubscribeOptions) {
|
||||
// WithQueue sets the Queue fielf on ConsumeOptions to the value provided
|
||||
func WithQueue(q string) ConsumeOption {
|
||||
return func(o *ConsumeOptions) {
|
||||
o.Queue = q
|
||||
}
|
||||
}
|
||||
|
||||
// WithStartAtTime sets the StartAtTime field on SubscribeOptions to the value provided
|
||||
func WithStartAtTime(t time.Time) SubscribeOption {
|
||||
return func(o *SubscribeOptions) {
|
||||
// WithStartAtTime sets the StartAtTime field on ConsumeOptions to the value provided
|
||||
func WithStartAtTime(t time.Time) ConsumeOption {
|
||||
return func(o *ConsumeOptions) {
|
||||
o.StartAtTime = t
|
||||
}
|
||||
}
|
||||
|
||||
// WithAutoAck sets the AutoAck field on SubscribeOptions and an ackWait duration after which if no ack is received
|
||||
// WithAutoAck sets the AutoAck field on ConsumeOptions and an ackWait duration after which if no ack is received
|
||||
// the message is requeued in case auto ack is turned off
|
||||
func WithAutoAck(ack bool, ackWait time.Duration) SubscribeOption {
|
||||
return func(o *SubscribeOptions) {
|
||||
func WithAutoAck(ack bool, ackWait time.Duration) ConsumeOption {
|
||||
return func(o *ConsumeOptions) {
|
||||
o.AutoAck = ack
|
||||
o.AckWait = ackWait
|
||||
}
|
||||
}
|
||||
|
||||
// WithRetryLimit sets the RetryLimit field on SubscribeOptions.
|
||||
// WithRetryLimit sets the RetryLimit field on ConsumeOptions.
|
||||
// Set to -1 for infinite retries (default)
|
||||
func WithRetryLimit(retries int) SubscribeOption {
|
||||
return func(o *SubscribeOptions) {
|
||||
func WithRetryLimit(retries int) ConsumeOption {
|
||||
return func(o *ConsumeOptions) {
|
||||
o.RetryLimit = retries
|
||||
o.CustomRetries = true
|
||||
}
|
||||
}
|
||||
|
||||
func (s SubscribeOptions) GetRetryLimit() int {
|
||||
func (s ConsumeOptions) GetRetryLimit() int {
|
||||
if !s.CustomRetries {
|
||||
return -1
|
||||
}
|
||||
|
Reference in New Issue
Block a user