Documentation ¶
Index ¶
- Variables
- func DecodeInt64(b []byte) int64
- func EncodeInt64(v int64) []byte
- func MessageKey(topic *Topic, offset *Offset) []byte
- func SnapshotKey(t *Topic, s *Subscription, name string) []byte
- func SubscriptionKey(topic *Topic, sub string) []byte
- func TopicKey(name string) []byte
- func UUID() []byte
- type Message
- type MessageID
- type Offset
- type Pubsub
- type ScanHandler
- type Snapshot
- type Subscription
- type Topic
- type Transaction
- func (txn *Transaction) Append(topic *Topic, messages ...*Message) ([]MessageID, error)
- func (txn *Transaction) Commit(ctx context.Context) error
- func (txn *Transaction) CreateSnapshot(topic *Topic, subscription *Subscription, name string) (*Snapshot, error)
- func (txn *Transaction) CreateSubscription(t *Topic, name string) (*Subscription, error)
- func (txn *Transaction) CreateTopic(name string) (*Topic, error)
- func (txn *Transaction) DeleteSnapshot(topic *Topic, subscription *Subscription, name string) error
- func (txn *Transaction) DeleteSubscription(t *Topic, name string) error
- func (txn *Transaction) DeleteTopic(name string) error
- func (txn *Transaction) GetSnapshot(topic *Topic, subscription *Subscription, name string) (*Snapshot, error)
- func (txn *Transaction) GetSnapshots(topic *Topic, subscription *Subscription) ([]*Snapshot, error)
- func (txn *Transaction) GetSubscription(t *Topic, name string) (*Subscription, error)
- func (txn *Transaction) GetSubscriptions(t *Topic) ([]*Subscription, error)
- func (txn *Transaction) GetTopic(name string) (*Topic, error)
- func (txn *Transaction) Rollback() error
- func (txn *Transaction) Scan(topic *Topic, offset *Offset, handler ScanHandler) error
- func (txn *Transaction) UpdateSubscription(t *Topic, s *Subscription) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func EncodeInt64 ¶
EncodeInt64 encodes an int64 to be memcomparable in asc order
func MessageKey ¶
MessageKey builds a key of a message
func SnapshotKey ¶
func SnapshotKey(t *Topic, s *Subscription, name string) []byte
SnapshotKey builds a key of a snapshot
func SubscriptionKey ¶
SubscriptionKey builds a key of a subscription
Types ¶
type Offset ¶
Offset is the position of a message in a topic
func OffsetFromBytes ¶
OffsetFromBytes parses offset from bytes
func OffsetFromString ¶
OffsetFromString parses offset from a string
type Pubsub ¶
type Pubsub struct {
// contains filtered or unexported fields
}
Pubsub is a storage with a pub/sub interface
type ScanHandler ¶
ScanHandler is a handler to process scanned messages
type Snapshot ¶
type Snapshot struct { Name string Subscription *Subscription }
Snapshot is an immutable state of a subscription
type Subscription ¶
Subscription keeps the state of subscribers
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction suppies the api to access pubsub
func (*Transaction) Append ¶
func (txn *Transaction) Append(topic *Topic, messages ...*Message) ([]MessageID, error)
Append a message to a topic
func (*Transaction) Commit ¶
func (txn *Transaction) Commit(ctx context.Context) error
Commit a transaction
func (*Transaction) CreateSnapshot ¶
func (txn *Transaction) CreateSnapshot(topic *Topic, subscription *Subscription, name string) (*Snapshot, error)
CreateSnapshot creates a snapshot for a subscription
func (*Transaction) CreateSubscription ¶
func (txn *Transaction) CreateSubscription(t *Topic, name string) (*Subscription, error)
CreateSubscritpion creates a subscription
func (*Transaction) CreateTopic ¶
func (txn *Transaction) CreateTopic(name string) (*Topic, error)
CreateTopic creates a topic, if the topic has existed, return it
func (*Transaction) DeleteSnapshot ¶
func (txn *Transaction) DeleteSnapshot(topic *Topic, subscription *Subscription, name string) error
DeleteSnapshot deletes a snapshot
func (*Transaction) DeleteSubscription ¶
func (txn *Transaction) DeleteSubscription(t *Topic, name string) error
DeleteSubscription deletes a subscription
func (*Transaction) DeleteTopic ¶
func (txn *Transaction) DeleteTopic(name string) error
DeleteTopic deletes a topic
func (*Transaction) GetSnapshot ¶
func (txn *Transaction) GetSnapshot(topic *Topic, subscription *Subscription, name string) (*Snapshot, error)
GetSnapshot returns a snapshot
func (*Transaction) GetSnapshots ¶
func (txn *Transaction) GetSnapshots(topic *Topic, subscription *Subscription) ([]*Snapshot, error)
GetSnapshots lists all snapshots of a subscription
func (*Transaction) GetSubscription ¶
func (txn *Transaction) GetSubscription(t *Topic, name string) (*Subscription, error)
GetSubscription returns a subscription
func (*Transaction) GetSubscriptions ¶
func (txn *Transaction) GetSubscriptions(t *Topic) ([]*Subscription, error)
GetSubscriptions lists all subscriptions of a topic
func (*Transaction) GetTopic ¶
func (txn *Transaction) GetTopic(name string) (*Topic, error)
GetTopic gets the topic information
func (*Transaction) Scan ¶
func (txn *Transaction) Scan(topic *Topic, offset *Offset, handler ScanHandler) error
Scan seeks to the offset and calls handler for each message
func (*Transaction) UpdateSubscription ¶
func (txn *Transaction) UpdateSubscription(t *Topic, s *Subscription) error
UpdateSubscription updates a subscription