{"modulePath":"github.com/infinitbyte/framework","version":"v1.0.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\n## Constants\n\n```go\nconst ConsumerOffsetBucket = \"queue_consumer_commit_offset\"\n```\n\n```go\nconst ReadComplete = EventType(\"ReadComplete\")\n```\n\n```go\nconst WriteComplete = EventType(\"WriteComplete\")\n```\n\n## Functions\n\n```go\nfunc GetDataPath(queueID string) string\n```\n\n```go\nfunc GetFileName(queueID string, segmentID int64) string\n```\n\n```go\nfunc GetLastCompressFileNum(queueID string) int64\n```\n\n```go\nfunc GetLastS3UploadFileNum(queueID string) int64\n```\n\n```go\nfunc Notify(queue string, eventType EventType, fileNum int64)\n```\n\n```go\nfunc RegisterEventListener(handler EventHandler)\n```\n\n```go\nfunc RemoveFile(cfg *DiskQueueConfig, queueID string, segmentID int64)\n```\n\n```go\nfunc SmartGetFileName(cfg *DiskQueueConfig, queueID string, segmentID int64) (string, bool, bool)\n```\nif local file not found, try to download from s3\n\n## Types\n\n```go\ntype CompressConfig struct {\n\tEnabled bool `config:\"enabled\"`\n\tLevel   int  `config:\"level\"`\n}\n```\n\n```go\ntype Consumer struct {\n\tID string\n\t// contains filtered or unexported fields\n}\n```\nNOTE: Consumer is not thread-safe\n\n```go\nfunc (d *Consumer) Close() error\n```\n\n```go\nfunc (this *Consumer) CommitOffset(offset queue.Offset) error\n```\n\n```go\nfunc (d *Consumer) FetchMessages(ctx *queue.Context, numOfMessages int) (messages []queue.Message, isTimeout bool, err error)\n```\n\n```go\nfunc (d *Consumer) ResetOffset(segment, readPos int64) error\n```\n\n```go\ntype Context struct {\n\tWriteFile    string `json:\"write_file_path\"`\n\tWriteFileNum int64  `json:\"write_file_num\"`\n}\n```\n\n```go\ntype DiskBasedQueue struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nproviding a filesystem backed FIFO queue\n\n```go\nfunc NewDiskQueueByConfig(name, dataPath string, cfg *DiskQueueConfig) *DiskBasedQueue\n```\nNewDiskQueue instantiates a new instance of DiskBasedQueue, retrieving metadata from the filesystem and starting the read ahead goroutine\n\n```go\nfunc (d *DiskBasedQueue) AcquireConsumer(qconfig *queue.QueueConfig, consumer *queue.ConsumerConfig, offset queue.Offset) (queue.ConsumerAPI, error)\n```\n\n```go\nfunc (d *DiskBasedQueue) Close() error\n```\nClose cleans up the queue and persists metadata\n\n```go\nfunc (d *DiskBasedQueue) Delete() error\n```\n\n```go\nfunc (d *DiskBasedQueue) DeleteSegmentConsumerInReading(consumerID string)\n```\n\n```go\nfunc (d *DiskBasedQueue) Depth() int64\n```\n\n```go\nfunc (d *DiskBasedQueue) Destroy() error\n```\nDestroy cleans up all data for the specified queue\n\n```go\nfunc (d *DiskBasedQueue) Empty() error\n```\nEmpty destructively clears out any pending data in the queue by fast forwarding read positions and removing intermediate files\n\n```go\nfunc (d *DiskBasedQueue) GetFileName(segmentID int64) string\n```\n\n```go\nfunc (d *DiskBasedQueue) LatestOffset() queue.Offset\n```\n\n```go\nfunc (d *DiskBasedQueue) Put(data []byte) WriteResponse\n```\nPut writes a \\[]byte to the queue\n\n```go\nfunc (d *DiskBasedQueue) ReadChan() \u003c-chan []byte\n```\nReadChan returns the receive-only \\[]byte channel for reading data\n\n```go\nfunc (d *DiskBasedQueue) ReadContext() Context\n```\nDepth returns the depth of the queue\n\n```go\nfunc (d *DiskBasedQueue) UpdateSegmentConsumerInReading(consumerID string, segment int64)\n```\n\n```go\ntype DiskCompress struct {\n\tDeleteAfterCompress       bool           `config:\"delete_after_compress\"`\n\tMessage                   CompressConfig `config:\"message\"`\n\tSegment                   CompressConfig `config:\"segment\"`\n\tIdleThreshold             int64          `config:\"idle_threshold\"`\n\tNumOfFilesDecompressAhead int64          `config:\"num_of_files_decompress_ahead\"`\n}\n```\n\n```go\ntype DiskQueue struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (module *DiskQueue) AcquireConsumer(qconfig *queue.QueueConfig, consumer *queue.ConsumerConfig) (queue.ConsumerAPI, error)\n```\n\n```go\nfunc (module *DiskQueue) AcquireProducer(cfg *queue.QueueConfig) (queue.ProducerAPI, error)\n```\n\n```go\nfunc (module *DiskQueue) Close(k string) error\n```\n\n```go\nfunc (module *DiskQueue) CommitOffset(k *queue.QueueConfig, consumer *queue.ConsumerConfig, offset queue.Offset) (bool, error)\n```\n\n```go\nfunc (module *DiskQueue) DeleteOffset(k *queue.QueueConfig, consumer *queue.ConsumerConfig) error\n```\n\n```go\nfunc (module *DiskQueue) Depth(k string) int64\n```\n\n```go\nfunc (module *DiskQueue) Destroy(k string) error\n```\n\n```go\nfunc (module *DiskQueue) GetEarlierOffsetByQueueID(queueID string) (int, int64)\n```\n\n```go\nfunc (module *DiskQueue) GetLatestOffsetByQueueID(queueID string) (int, int64)\n```\n\n```go\nfunc (module *DiskQueue) GetOffset(k *queue.QueueConfig, consumer *queue.ConsumerConfig) (queue.Offset, error)\n```\n\n```go\nfunc (module *DiskQueue) GetQueues() []string\n```\n\n```go\nfunc (module *DiskQueue) GetStorageSize(k string) uint64\n```\n\n```go\nfunc (module *DiskQueue) Init(name string) error\n```\n\n```go\nfunc (module *DiskQueue) LatestOffset(k *queue.QueueConfig) queue.Offset\n```\n\n```go\nfunc (module *DiskQueue) Name() string\n```\n\n```go\nfunc (module *DiskQueue) Pop(k string, timeoutDuration time.Duration) (data []byte, timeout bool)\n```\n\n```go\nfunc (module *DiskQueue) Push(k string, v []byte) error\n```\n\n```go\nfunc (module *DiskQueue) ReadChan(k string) \u003c-chan []byte\n```\n\n```go\nfunc (this *DiskQueue) ReleaseConsumer(qconfig *queue.QueueConfig, consumer *queue.ConsumerConfig, instance queue.ConsumerAPI) error\n```\n\n```go\nfunc (this *DiskQueue) ReleaseProducer(k *queue.QueueConfig, producer queue.ProducerAPI) error\n```\n\n```go\nfunc (module *DiskQueue) Setup()\n```\n\n```go\nfunc (module *DiskQueue) Start() error\n```\n\n```go\nfunc (module *DiskQueue) Stop() error\n```\n\n```go\ntype DiskQueueConfig struct {\n\tMinMsgSize       int32 `config:\"min_msg_size\"`\n\tMaxMsgSize       int32 `config:\"max_msg_size\"`\n\tMaxBytesPerFile  int64 `config:\"max_bytes_per_file\"`\n\tSyncEveryRecords int64 `config:\"sync_every_records\"`\n\tSyncTimeoutInMS  int   `config:\"sync_timeout_in_ms\"`\n\tNotifyChanBuffer int   `config:\"notify_chan_buffer_size\"`\n\tReadChanBuffer   int   `config:\"read_chan_buffer_size\"`\n\tWriteChanBuffer  int   `config:\"write_chan_buffer_size\"`\n\n\tWriteTimeoutInMS  int64 `config:\"write_timeout_in_ms\" json:\"write_timeout_in_ms,omitempty\"`\n\tEOFRetryDelayInMs int64 `config:\"eof_retry_delay_in_ms\" json:\"eof_retry_delay_in_ms,omitempty\"`\n\n\tMaxUsedBytes      uint64 `config:\"max_used_bytes\"`\n\tWarningFreeBytes  uint64 `config:\"warning_free_bytes\"`\n\tReservedFreeBytes uint64 `config:\"reserved_free_bytes\"`\n\n\tAutoSkipCorruptFile bool `config:\"auto_skip_corrupted_file\"`\n\n\tUploadToS3     bool `config:\"upload_to_s3\"`\n\tAlwaysDownload bool `config:\"always_download\"`\n\n\tPrepareFilesToRead bool `config:\"prepare_files_to_read\"`\n\n\tCompressAndCleanupDuringInit bool `config:\"cleanup_files_on_init\"`\n\n\t//default queue adaptor\n\tDefault bool `config:\"default\"`\n\tEnabled bool `config:\"enabled\"`\n\n\tSkipZeroConsumers bool `config:\"skip_zero_consumers\"`\n\n\tCompress DiskCompress `config:\"compress\"`\n\n\tRetention RetentionConfig `config:\"retention\"`\n\n\tS3 config.S3BucketConfig `config:\"s3\"`\n}\n```\n\n```go\ntype Event struct {\n\tQueue   string\n\tType    EventType\n\tFileNum int64\n}\n```\n\n```go\ntype EventHandler func(event Event) error\n```\n\n```go\ntype EventType string\n```\n\n```go\ntype Message struct {\n\tPayload *bytebufferpool.ByteBuffer\n\tContext Context\n}\n```\n\n```go\ntype Producer struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (p *Producer) Close() error\n```\n\n```go\nfunc (p *Producer) Produce(reqs *[]queue.ProduceRequest) (*[]queue.ProduceResponse, error)\n```\n\n```go\ntype RetentionConfig struct {\n\tMaxNumOfLocalFiles int64 `config:\"max_num_of_local_files\"`\n}\n```\n\n```go\ntype WriteResponse struct {\n\tSegment  int64\n\tPosition int64\n\tError    error\n}\n```\n\n","path":"github.com/infinitbyte/framework/modules/queue/disk_queue","name":"queue","synopsis":"","isRedistributable":true}
