{"modulePath":"github.com/infinitbyte/framework","version":"v1.1.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\n## Constants\n\n```go\nconst BucketWhoOwnsThisTopic = \"who_owns_this_topic\" //queue_group: node_id/timestamp\n\n```\n\n```go\nconst ConsumerBucket = \"queue_consumers\"\n```\n\n## Functions\n\n```go\nfunc Close(k *QueueConfig) error\n```\n\n```go\nfunc CommitOffset(k *QueueConfig, consumer *ConsumerConfig, offset Offset) (bool, error)\n```\n\n```go\nfunc ConsumerHasLag(k *QueueConfig, c *ConsumerConfig) bool\n```\n\n```go\nfunc ConvertOffset(offsetStr string) (int64, int64)\n```\n\n```go\nfunc DeleteOffset(k *QueueConfig, consumer *ConsumerConfig) error\n```\n\n```go\nfunc Depth(k *QueueConfig) int64\n```\n\n```go\nfunc Destroy(k *QueueConfig) error\n```\n\n```go\nfunc ExtendConvertOffset(offsetStr string) (int64, int64, int64)\n```\n\n```go\nfunc GetAllConfigBytes() []byte\n```\n\n```go\nfunc GetAllConfigs() map[string]*QueueConfig\n```\n\n```go\nfunc GetConsumerConfigsByQueueID(queueID string) (map[string]*ConsumerConfig, bool)\n```\n\n```go\nfunc GetEarlierOffsetByQueueID(queueID string) (consumerSize int, segment int64, pos, ver int64)\n```\n\n```go\nfunc GetLatestOffsetByQueueID(queueID string) (consumerSize int, segment int64, pos int64)\n```\n\n```go\nfunc GetQueues() map[string][]string\n```\n\n```go\nfunc GetStorageSize(k string) uint64\n```\n\n```go\nfunc HasLag(k *QueueConfig) bool\n```\n\n```go\nfunc IniQueue(k *QueueConfig)\n```\n\n```go\nfunc IsConfigExists(key string) bool\n```\n\n```go\nfunc Itoa64(i int64) string\n```\n\n```go\nfunc Pop(k *QueueConfig) ([]byte, error)\n```\n\n```go\nfunc PopTimeout(k *QueueConfig, timeoutInSeconds time.Duration) (data []byte, timeout bool, err error)\n```\n\n```go\nfunc Push(k *QueueConfig, v []byte) error\n```\n\n```go\nfunc Register(name string, h QueueAPI)\n```\n\n```go\nfunc RegisterConfig(cfg *QueueConfig) (preExists bool, err error)\n```\n\n```go\nfunc RegisterConsumer(queueID string, consumer *ConsumerConfig) (bool, error)\n```\n\n```go\nfunc RegisterConsumerConfigChangeListener(l func(id string, configs map[string]*ConsumerConfig))\n```\n\n```go\nfunc RegisterDefaultHandler(h QueueAPI)\n```\n\n```go\nfunc RegisterQueueConfigChangeListener(l func(cfg *QueueConfig))\n```\n\n```go\nfunc ReleaseConsumer(k *QueueConfig, c *ConsumerConfig, consumer ConsumerAPI) error\n```\n\n```go\nfunc RemoveAllConsumers(qConfig *QueueConfig) (bool, error)\n```\n\n```go\nfunc RemoveConfig(cfg *QueueConfig) bool\n```\n\n```go\nfunc RemoveConsumer(queueID string, consumerKey string) (bool, error)\n```\n\n```go\nfunc ReturnQueueConfig(cfg *QueueConfig)\n```\n\n```go\nfunc TriggerChangeEvent(queueID string, cfgs map[string]*ConsumerConfig, async bool)\n```\n\n## Types\n\n```go\ntype AdvancedQueueAPI interface {\n\tQueueAPI\n\n\tLatestOffset(k *QueueConfig) Offset\n\tGetOffset(k *QueueConfig, consumer *ConsumerConfig) (Offset, error)\n\tDeleteOffset(k *QueueConfig, consumer *ConsumerConfig) error\n\tCommitOffset(k *QueueConfig, consumer *ConsumerConfig, offset Offset) (bool, error)\n\n\tAcquireConsumer(k *QueueConfig, consumer *ConsumerConfig) (ConsumerAPI, error)\n\tReleaseConsumer(k *QueueConfig, c *ConsumerConfig, consumer ConsumerAPI) error\n\n\tAcquireProducer(cfg *QueueConfig) (ProducerAPI, error)\n\tReleaseProducer(k *QueueConfig, producer ProducerAPI) error\n}\n```\n\n```go\ntype ConsumerAPI interface {\n\tClose() error\n\tResetOffset(segment, readPos int64) (err error)\n\tFetchMessages(ctx *Context, numOfMessages int) (messages []Message, isTimeout bool, err error)\n\tCommitOffset(offset Offset) error\n}\n```\n\n```go\nfunc AcquireConsumer(k *QueueConfig, consumer *ConsumerConfig, clientID string) (ConsumerAPI, error)\n```\n\n```go\ntype ConsumerConfig struct {\n\torm.ORMObjectBase\n\n\tSource           string `config:\"source\" json:\"source,omitempty\"`\n\tGroup            string `config:\"group\" json:\"group,omitempty\"`\n\tName             string `config:\"name\" json:\"name,omitempty\"`\n\tAutoResetOffset  string `config:\"auto_reset_offset\" json:\"auto_reset_offset,omitempty\"`\n\tAutoCommitOffset bool   `config:\"auto_commit_offset\" json:\"auto_commit_offset,omitempty\"`\n\n\t//don't add queue id to generated sliced consumer group\n\tSimpleSlicedGroup bool `config:\"simple_sliced_group\" json:\"simple_sliced_group,omitempty\"`\n\n\tFetchMinBytes           int   `config:\"fetch_min_bytes\" json:\"fetch_min_bytes,omitempty\"`\n\tFetchMaxBytes           int   `config:\"fetch_max_bytes\" json:\"fetch_max_bytes,omitempty\"`\n\tFetchMaxMessages        int   `config:\"fetch_max_messages\" json:\"fetch_max_messages,omitempty\"`\n\tFetchMaxWaitMs          int64 `config:\"fetch_max_wait_ms\" json:\"fetch_max_wait_ms,omitempty\"`\n\tConsumeTimeoutInSeconds int   `config:\"consume_timeout\" json:\"consume_timeout,omitempty\"`\n\tEOFMaxRetryTimes        int   `config:\"eof_max_retry_times\" json:\"eof_max_retry_times,omitempty\"`\n\tEOFRetryDelayInMs       int64 `config:\"eof_retry_delay_in_ms\" json:\"eof_retry_delay_in_ms,omitempty\"`\n\n\tClientExpiredInSeconds int64 `config:\"client_expired_in_seconds\" json:\"client_expired_in_seconds,omitempty\"` //client acquires lock for this long\n\n\tCommitLocker sync.Mutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc GetConsumerConfig(queueID, group, name string) (*ConsumerConfig, bool)\n```\n\n```go\nfunc GetConsumerConfigID(queueID, consumerID string) (*ConsumerConfig, bool)\n```\n\n```go\nfunc GetOrInitConsumerConfig(queueID, group, name string) *ConsumerConfig\n```\n\n```go\nfunc NewConsumerConfig(queueID, group, name string) *ConsumerConfig\n```\n\n```go\nfunc (cfg *ConsumerConfig) GetFetchMaxWaitMs() time.Duration\n```\n\n```go\nfunc (cfg *ConsumerConfig) GetLastActiveTime() *time.Time\n```\n\n```go\nfunc (cfg *ConsumerConfig) KeepActive()\n```\n\n```go\nfunc (cfg *ConsumerConfig) Key() string\n```\n\n```go\nfunc (cfg *ConsumerConfig) String() string\n```\n\n```go\ntype ConsumerInstanceInfo struct {\n\tID        string    `config:\"id\" json:\"id,omitempty\"`\n\tTimestamp time.Time `config:\"timestamp\" json:\"timestamp,omitempty\"`\n}\n```\n\n```go\ntype Context struct {\n\tMessageCount int    `config:\"message_count\" json:\"message_count\"`\n\tNextOffset   Offset `config:\"next_offset\" json:\"next_offset\"`\n\tInitOffset   Offset `config:\"init_offset\" json:\"init_offset\"`\n}\n```\n\n```go\nfunc (c *Context) String() string\n```\n\n```go\nfunc (c *Context) UpdateInitOffset(seg, pos, ver int64)\n```\n\n```go\nfunc (c *Context) UpdateNextOffset(seg, pos int64)\n```\n\n```go\nfunc (c *Context) Valid() bool\n```\n\n```go\ntype Message struct {\n\tTimestamp  int64  `config:\"timestamp\" json:\"timestamp\" parquet:\"timestamp\"`\n\tOffset     Offset `config:\"offset\" json:\"offset\"  parquet:\"offset\"`                //current offset\n\tNextOffset Offset `config:\"next_offset\" json:\"next_offset\"  parquet:\"next_offset\"` //offset for next message\n\tSize       int    `config:\"size\" json:\"size\"  parquet:\"size\"`\n\tData       []byte `config:\"data\" json:\"data\"  parquet:\"data,zstd\"`\n}\n```\n\n```go\nfunc (m *Message) String() string\n```\n\n```go\ntype Offset struct {\n\tSegment  int64 `json:\"segment\"`\n\tPosition int64 `json:\"position\"`\n\tVersion  int64 `json:\"version\"`\n}\n```\n\n```go\nfunc AcquireOffset(seg, pos int64) Offset\n```\n\n```go\nfunc DecodeFromString(offsetStr string) Offset\n```\n\n```go\nfunc GetEarlierOffsetStrByQueueID(queueID string) Offset\n```\n\n```go\nfunc GetOffset(k *QueueConfig, consumer *ConsumerConfig) (Offset, error)\n```\n\n```go\nfunc LatestOffset(k *QueueConfig) Offset\n```\n\n```go\nfunc NewOffset(seg, pos int64) Offset\n```\n\n```go\nfunc NewOffsetWithVersion(seg, pos, ver int64) Offset\n```\n\n```go\nfunc (c *Offset) EncodeToString() string\n```\n\n```go\nfunc (c *Offset) Equals(v Offset) bool\n```\n\n```go\nfunc (c *Offset) LatestThan(v Offset) bool\n```\n\n```go\nfunc (c *Offset) String() string\n```\n\n```go\ntype ProduceRequest struct {\n\tTopic string `config:\"topic\" json:\"topic\"` //queue_id\n\tKey   []byte `config:\"key\" json:\"key\"`\n\tData  []byte `config:\"data\" json:\"data\"`\n}\n```\n\n```go\ntype ProduceResponse struct {\n\tTopic     string `config:\"topic\" json:\"topic\"`\n\tPartition int64  `config:\"partition\" json:\"partition\"`\n\tOffset    Offset `config:\"offset\" json:\"offset\"`\n\tTimestamp int64  `config:\"timestamp\" json:\"timestamp\"`\n}\n```\n\n```go\ntype ProducerAPI interface {\n\tProduce(*[]ProduceRequest) (*[]ProduceResponse, error)\n\tClose() error\n}\n```\n\n```go\nfunc AcquireProducer(cfg *QueueConfig) (ProducerAPI, error)\n```\n\n```go\ntype QueueAPI interface {\n\tName() string\n\tInit(string) error\n\tClose(string) error\n\tGetStorageSize(k string) uint64\n\tDestroy(string) error\n\tGetQueues() []string\n\n\tPush(string, []byte) error\n}\n```\n\n```go\nfunc GetHandlerByType(t string) QueueAPI\n```\n\n```go\ntype QueueConfig struct {\n\tID      string      `config:\"id\" json:\"id,omitempty\"`     //uuid for each queue\n\tName    string      `config:\"name\" json:\"name,omitempty\"` //unique name of each queue\n\tSource  string      `config:\"source\" json:\"source,omitempty\"`\n\tCodec   string      `config:\"codec\" json:\"codec,omitempty\"`\n\tType    string      `config:\"type\" json:\"type,omitempty\"`\n\tCreated string      `config:\"created\" json:\"created,omitempty\"`\n\tLabels  util.MapStr `config:\"label\" json:\"label,omitempty\"`\n\tsync.RWMutex\n}\n```\n\n```go\nfunc AcquireQueueConfig() *QueueConfig\n```\n\n```go\nfunc AdvancedGetOrInitConfig(queueType, key string, labels map[string]interface{}) *QueueConfig\n```\n\n```go\nfunc GetConfigByKey(key string) (*QueueConfig, bool)\n```\n\n```go\nfunc GetConfigByLabels(labels map[string]interface{}) []*QueueConfig\n```\n\n```go\nfunc GetConfigBySelector(selector *QueueSelector) []*QueueConfig\n```\n\n```go\nfunc GetConfigByUUID(id string) (*QueueConfig, bool)\n```\n\n```go\nfunc GetOrInitConfig(key string) *QueueConfig\n```\n\n```go\nfunc SmartGetConfig(keyOrID string) (*QueueConfig, bool)\n```\n\n```go\nfunc SmartGetOrInitConfig(cfg *QueueConfig) *QueueConfig\n```\n\n```go\nfunc (q *QueueConfig) ReplaceLabels(labels util.MapStr)\n```\n\n```go\nfunc (q *QueueConfig) UpdateLabel(key string, val interface{})\n```\n\n```go\ntype QueueSelector struct {\n\tLabels map[string]interface{} `config:\"labels,omitempty\"`\n\tIds    []string               `config:\"ids,omitempty\"`\n\tKeys   []string               `config:\"keys,omitempty\"`\n}\n```\n\n```go\nfunc (s *QueueSelector) ToString() string\n```\n\n```go\ntype SimpleQueueAPI interface {\n\tQueueAPI\n\tPop(string, time.Duration) (data []byte, timeout bool)\n\tDepth(string) int64\n}\n```\n\n","path":"github.com/infinitbyte/framework/core/queue","name":"queue","synopsis":"","isRedistributable":true}
