Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrFullTopic indicates this topic is full, and can not put anymore. ErrFullTopic = errors.New("full topic") // ErrClosedTopic indicates put to closed topic ErrClosedTopic = errors.New("closed topic") // ErrInvalidMsg indicates an invalid message ErrInvalidMsg = errors.New("invalid message") // ErrTooLargeMsg indicates message length exceed the max cap. ErrTooLargeMsg = errors.New("too large message") )
View Source
var DefaultConfig = &Config{
QueueCap: 8000,
TopicCap: 2 << 20,
MsgCap: 1 << 10,
}
DefaultConfig use up to 16GB memory with max 8000 topics, 2MB per topic, 1KB per message.
View Source
var ( // ErrOutOfTopic indicates can not create topics anymore. ErrOutOfTopic = errors.New("out of topic") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { QueueCap int // max num of topics a queue can hold TopicCap int // max memory size of messages a topic can hold MsgCap int // max length of a message }
Config the message queue.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message can be put to or get from a topic.
type Queue ¶
type Queue struct { *Config // contains filtered or unexported fields }
Queue can have many topics, all messages are kept in memory.
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
Topic is a FIFO queue to put and get messages.
func (*Topic) Close ¶
Close marks this topic as closed. Message can not be put to this topic after closed, but is still able to read pending messages.
Click to show internal directories.
Click to hide internal directories.