github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/cluster/config_opts.go (about) 1 package cluster 2 3 import "time" 4 5 type ConfigOption func(config *Config) 6 7 // WithRequestTimeout sets the request timeout. 8 func WithRequestTimeout(t time.Duration) ConfigOption { 9 return func(c *Config) { 10 c.RequestTimeoutTime = t 11 } 12 } 13 14 // WithRequestsLogThrottlePeriod sets the requests log throttle period. 15 func WithRequestsLogThrottlePeriod(period time.Duration) ConfigOption { 16 return func(c *Config) { 17 c.RequestsLogThrottlePeriod = period 18 } 19 } 20 21 // WithClusterContextProducer sets the cluster context producer. 22 func WithClusterContextProducer(producer ContextProducer) ConfigOption { 23 return func(c *Config) { 24 c.ClusterContextProducer = producer 25 } 26 } 27 28 // WithMaxNumberOfEventsInRequestLogThrottlePeriod sets the max number of events in request log throttled period. 29 func WithMaxNumberOfEventsInRequestLogThrottlePeriod(maxNumber int) ConfigOption { 30 return func(c *Config) { 31 c.MaxNumberOfEventsInRequestLogThrottledPeriod = maxNumber 32 } 33 } 34 35 func WithKinds(kinds ...*Kind) ConfigOption { 36 return func(c *Config) { 37 for _, kind := range kinds { 38 c.Kinds[kind.Kind] = kind 39 } 40 } 41 } 42 43 // WithPubSubSubscriberTimeout sets a timeout used when delivering a message batch to a subscriber. 44 // Default is 5s. 45 func WithPubSubSubscriberTimeout(timeout time.Duration) ConfigOption { 46 return func(c *Config) { 47 c.PubSubConfig.SubscriberTimeout = timeout 48 } 49 } 50 51 // WithHeartbeatExpiration sets the gossip heartbeat expiration. 52 func WithHeartbeatExpiration(t time.Duration) ConfigOption { 53 return func(c *Config) { 54 c.HeartbeatExpiration = t 55 } 56 }