dcomponent

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LangZhCN = "zh-CN" //简体中文
	LangEN   = "en"    //简体中文
	LangJA   = "en"    //简体中文
	LangDE   = "de"    //简体中文
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncTask

type AsyncTask[T any] struct {
	// contains filtered or unexported fields
}

func NewAsyncTask

func NewAsyncTask[T any](broker Broker[T]) *AsyncTask[T]

func (*AsyncTask[T]) NewWorkers

func (t *AsyncTask[T]) NewWorkers(ctx context.Context, workers int, doFunc func(task T))

func (*AsyncTask[T]) Produce

func (t *AsyncTask[T]) Produce(ctx context.Context, task T) error

type Broker

type Broker[T any] interface {
	Produce(ctx context.Context, task T) error
	Subscribe(ctx context.Context, cb func(task T))
}

type Cache

type Cache interface {
	//Set save the data to the cache
	Set(ctx context.Context, key string, value interface{}, expire time.Duration) error
	//SetNX save the data to the cache if not exist
	SetNX(ctx context.Context, key string, value interface{}, expire time.Duration) error
	//SetHash save the data to hash cache
	SetHash(ctx context.Context, key, field string, value interface{}) error
	//UpdateExpire update the data expire time
	UpdateExpire(ctx context.Context, key string, expire time.Duration) error
	//Get get data from cache
	Get(ctx context.Context, key string, value interface{}) error
	MGet(ctx context.Context, keys []string, value interface{}) error
	//GetHash get the data to hash cache
	GetHash(ctx context.Context, key, field string, value interface{}) error
	//Keys get the keys match pattern
	Keys(ctx context.Context, pattern string) ([]string, error)
	//Exist Judge whether the key is existed
	Exist(ctx context.Context, key string) (bool, error)
	//SetAdd save unsorted list data to the cache
	SetAdd(ctx context.Context, key string, member interface{}) error
	//IsSetMember Judge whether the element is existed in the unsorted set
	IsSetMember(ctx context.Context, key string, member interface{}) (bool, error)
	//DelSetMember delete the member form the  unsorted list
	DelSetMember(ctx context.Context, key string, member ...interface{}) error
	//SetList save sorted list data to the cache
	SetList(ctx context.Context, key string, value interface{}) error
	//GetList get sorted list data from the cache
	GetList(ctx context.Context, key string, value interface{}) error
	//Delete delete cache
	Delete(ctx context.Context, key ...string) error
	//Name cache name
	Name() string
}

Cache represents interface of data cache

type DLock

type DLock interface {
	Lock(key string, timeout time.Duration) error
	TryLock(key string, timeout time.Duration) (bool, error)
	Unlock(key string) error
}

type I18nTranslator

type I18nTranslator interface {
	//Add add translation to i18n server
	Add(ctx context.Context, lang, key, trans string) error
	//Delete delete translation from i18n server
	Delete(ctx context.Context, lang, key string) error
	//Update update translation from i18n server
	Update(ctx context.Context, lang, key, trans string) error
	//TranslateKey translate key to language lang
	TranslateKey(ctx context.Context, lang, key string) string
	//Translate translate object i to language lang
	Translate(ctx context.Context, lang string, i interface{})
}

type Publisher

type Publisher interface {
	Product(ctx context.Context, topic string, message interface{}, messageExpiration time.Duration) error //Product 生产者模型,pub message,qos: Transient (0 or 1) or Persistent (2)
	Publish(ctx context.Context, topic string, message interface{}, messageExpiration time.Duration) error //广播模式
}

type RpcPublisher

type RpcPublisher interface {
	RpcPublish(ctx context.Context, topic, replyTopic string, message, replyMessage interface{}, timeout time.Duration) error
}

type RpcSubscriber

type RpcSubscriber interface {
	RpcSubscribe(ctx context.Context, topic string, message interface{}, handler interface{})
}

type Subscriber

type Subscriber interface {
	Consume(ctx context.Context, topic string, message interface{}, handler interface{})   //Consume 消费者模型
	Subscribe(ctx context.Context, topic string, message interface{}, handler interface{}) //话题订阅模式
}

Jump to

Keyboard shortcuts

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