storage

package
v1.1.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixKey = "__host"
)

Variables

This section is empty.

Functions

func WithRabbitMqConsumeOptionsBindingExchangeName added in v0.3.7

func WithRabbitMqConsumeOptionsBindingExchangeName(name string) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsBindingExchangeName returns a function that sets the exchange name the queue will be bound to

func WithRabbitMqConsumeOptionsBindingExchangeType added in v0.3.7

func WithRabbitMqConsumeOptionsBindingExchangeType(kind string) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsBindingExchangeType returns a function that sets the binding exchange kind/type

func WithRabbitMqConsumeOptionsBindingRoutingKeys added in v0.3.7

func WithRabbitMqConsumeOptionsBindingRoutingKeys(keys []string) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsBindingRoutingKeys returns a function that sets the exchange name the RoutingKeys will be bound to

func WithRabbitMqConsumeOptionsConcurrency added in v0.3.7

func WithRabbitMqConsumeOptionsConcurrency(concurrency int) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsConcurrency returns a function that sets the concurrency, which means that many goroutines will be spawned to run the provided handler on messages

func WithRabbitMqConsumeOptionsConsumerAutoAck added in v0.3.7

func WithRabbitMqConsumeOptionsConsumerAutoAck(autoAck bool) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsConsumerAutoAck returns a function that sets the auto acknowledge property on the server of this consumer if unset the default will be used (false)

func WithRabbitMqConsumeOptionsConsumerName added in v0.3.7

func WithRabbitMqConsumeOptionsConsumerName(consumerName string) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsConsumerName returns a function that sets the name on the server of this consumer if unset a random name will be given

func WithRabbitMqConsumeOptionsQOSPrefetch added in v0.3.7

func WithRabbitMqConsumeOptionsQOSPrefetch(prefetchCount int) func(*ConsumeOptions)

WithRabbitMqConsumeOptionsQOSPrefetch returns a function that sets the prefetch count, which means that many messages will be fetched from the server in advance to help with throughput. This doesn't affect the handler, messages are still processed one at a time.

func WithRabbitMqPublishOptionsAppID added in v0.3.7

func WithRabbitMqPublishOptionsAppID(appID string) func(*PublishOptions)

WithRabbitMqPublishOptionsAppID returns a function that sets the application id

func WithRabbitMqPublishOptionsContentType added in v0.3.7

func WithRabbitMqPublishOptionsContentType(contentType string) func(*PublishOptions)

WithRabbitMqPublishOptionsContentType returns a function that sets the content type, i.e. "application/json"

func WithRabbitMqPublishOptionsExchange added in v0.3.7

func WithRabbitMqPublishOptionsExchange(exchange string) func(*PublishOptions)

WithRabbitMqPublishOptionsExchange returns a function that sets the exchange to publish to

func WithRabbitMqPublishOptionsMessageID added in v0.3.7

func WithRabbitMqPublishOptionsMessageID(messageID string) func(*PublishOptions)

WithRabbitMqPublishOptionsMessageID returns a function that sets the message identifier

func WithRabbitMqPublishOptionsReplyTo added in v0.3.7

func WithRabbitMqPublishOptionsReplyTo(replyTo string) func(*PublishOptions)

WithRabbitMqPublishOptionsReplyTo returns a function that sets the reply to field

func WithRabbitMqPublishOptionsUserID added in v0.3.7

func WithRabbitMqPublishOptionsUserID(userID string) func(*PublishOptions)

WithRabbitMqPublishOptionsUserID returns a function that sets the user id i.e. "user"

func WithRocketMqAutoCommit added in v0.3.7

func WithRocketMqAutoCommit(auto bool) func(*ConsumeOptions)

func WithRocketMqGroupName added in v0.3.7

func WithRocketMqGroupName(name string) func(*ConsumeOptions)

WithRocketMqGroupName set group name address

func WithRocketMqMaxReconsumeTimes added in v0.3.7

func WithRocketMqMaxReconsumeTimes(times int32) func(*ConsumeOptions)

WithRocketMqMaxReconsumeTimes set MaxReconsumeTimes of options, if message reconsume greater than MaxReconsumeTimes, it will be sent to retry or dlq topic. more info reference by examples/consumer/retry.

func WithRocketMqPublishGroupName added in v0.3.7

func WithRocketMqPublishGroupName(name string) func(*PublishOptions)

WithRocketMqPublishGroupName set group name address

func WithRocketMqPublishRetry added in v0.3.7

func WithRocketMqPublishRetry(times int) func(*PublishOptions)

WithRocketMqPublishRetry return a Option that specifies the retry times when send failed.

Types

type AdapterCache

type AdapterCache interface {
	String() string
	Get(ctx context.Context, key string) (*gvar.Var, error)
	Set(ctx context.Context, key string, val interface{}, expire int) error
	Del(ctx context.Context, key string) error
	HashGet(ctx context.Context, hk, key string) (*gvar.Var, error)
	HashDel(ctx context.Context, hk, key string) error
	Increase(ctx context.Context, key string) error
	Decrease(ctx context.Context, key string) error
	Expire(ctx context.Context, key string, dur time.Duration) error
}

type AdapterLocker

type AdapterLocker interface {
	String() string
	Lock(key string, ttl int64, options ...redislock.Option) (*redislock.Mutex, error)
}

type AdapterQueue

type AdapterQueue interface {
	String() string
	Publish(ctx context.Context, message Messager, optionFuncs ...func(*PublishOptions)) error
	Consumer(ctx context.Context, name string, f ConsumerFunc, optionFuncs ...func(*ConsumeOptions))
	Run(ctx context.Context)
	Shutdown(ctx context.Context)
}

type BindingExchangeOptions

type BindingExchangeOptions struct {
	Name string
	Kind string
}

BindingExchangeOptions are used when binding to an exchange. it will verify the exchange is created before binding to it.

type ConsumeOptions

type ConsumeOptions struct {
	// rabbitmq
	BindingRoutingKeys []string
	BindingExchange    *BindingExchangeOptions
	Concurrency        int
	QOSPrefetch        int
	ConsumerName       string
	ConsumerAutoAck    bool
	// rocketmq
	GroupName         string
	MaxReconsumeTimes int32
	AutoCommit        bool
}

ConsumeOptions are used to describe how a new consumer will be created.

func GetDefaultConsumeOptions

func GetDefaultConsumeOptions() ConsumeOptions

GetDefaultConsumeOptions descibes the options that will be used when a value isn't provided

type ConsumerFunc

type ConsumerFunc func(ctx context.Context, msg Messager) error

type Messager

type Messager interface {
	SetId(string)
	GetId() string
	SetRoutingKey(string)
	GetRoutingKey() string
	SetValues(map[string]interface{})
	GetValues() map[string]interface{}
	GetPrefix() string
	SetPrefix(string)
	SetErrorIncr()
	SetErrorCount(uint64)
	GetErrorCount() uint64
}

type PublishOptions

type PublishOptions struct {
	Exchange string
	// MIME content type
	ContentType string
	// address to to reply to (ex: RPC)
	ReplyTo string
	// message identifier
	MessageID string
	// creating user id - ex: "guest"
	UserID string
	// creating application id
	AppID string

	// rocketmq
	GroupName  string
	RetryTimes int
}

PublishOptions are used to control how data is published

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL