Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefaultRotateThreshold = filechannel.DefaultRotateThreshold DefaultFlushInterval = filechannel.DefaultFlushInterval RotateThreshold = filechannel.RotateThreshold FlushInterval = filechannel.FlushInterval )
Default option values and options.
Functions ¶
This section is empty.
Types ¶
type AckFileChannel ¶
type AckFileChannel interface { FileChannel // RxAck creates a AckReceiver. AckReceiver behaves the same as // Receiver from [FileChannel.Rx] except the ack. Like Receiver, // there also can be multiple AckReceiver at the same time. RxAck() AckReceiver }
AckFileChannel is the interface for a file-based persistent channel that supports asynchronous ack of received messages.
func OpenAckFileChannel ¶
func OpenAckFileChannel(dir string, opts ...Option) (AckFileChannel, error)
OpenAckFileChannel opens a new AckFileChannel.
type AckReceiver ¶
type AckReceiver interface { Receiver // Ack consumes the front unacknowledged messages. Ack(n int) error }
AckReceiver receives bytes like Receiver. However, it doesn't consume the data until a manual Ack is invoked. Consuming a data means telling the file channel that the data can be purged.
type FileChannel ¶
type FileChannel interface { Stats // Tx creates a Sender. Sender is thread safe. // It's possible to have multiple senders at the same time. Tx() Sender // Rx creates a Receiver. Be careful that Receiver is non-thread safe. // However, it's possible to have multiple receivers at the same time. // The first message received by each receiver is undetermined and // leaved to implementation. Rx() Receiver // Close the channel. Unclosed senders will block the method. Close() error }
FileChannel is the interface for a file-based persistent channel.
func OpenFileChannel ¶
func OpenFileChannel(dir string, opts ...Option) (FileChannel, error)
OpenFileChannel opens a new FileChannel.
type Receiver ¶
type Receiver interface { ReceiverStats // Recv bytes from file channel. Recv(context.Context) ([]byte, error) // Close closes the reader. Close() error }
Receiver receives bytes from file channel in the sending order.
type ReceiverStats ¶ added in v0.1.1
type ReceiverStats interface { // ReadOffset returns the offset of the last read message. // Note that the offset is local to the receiver. It will only change // when the receiver reads a message. // // The initial offset is math.MaxUint64 to indicate that no message has // been read. ReadOffset() uint64 }
ReceiverStats is the interface for getting the stats of a receiver.
type Sender ¶
type Sender interface { SenderStats // Send bytes to file channel. Data will be finally persistent on disk. Send(context.Context, []byte) error // Close closes a sender. Close() error }
Sender sends bytes to file channel.
type SenderStats ¶ added in v0.1.1
type SenderStats interface { // WriteOffset returns the offset of the last written message. // Note that the offset is not the byte offset in the file. It's the // offset of the message in the channel. The offset will change no matter // a message is written by the sender, or the other senders of the same // channel. WriteOffset() uint64 }
SenderStats is the interface for getting the stats of a sender.
type Stats ¶ added in v0.1.1
type Stats interface { // DiskUsage returns the disk usage of the file channel. // Note that calling DiskUsage() is an expensive operation. DiskUsage() (uint64, error) // FlushOffset returns the offset of the last flushed message. // Messages with offset less than the flush offset are guaranteed to be // seen by the readers. FlushOffset() uint64 }
Stats is the interface for getting the stats of a file channel.