Documentation
¶
Index ¶
- Constants
- func GenerateSubscriptionID() (string, error)
- func LogNKey(topic int) string
- func LogNTextKey(topic int) string
- func PublishAll(ctx context.Context, subscribable Subscribable, subscriber string, ...) error
- func QueryForEventID(eventID string) *query.Builder
- func SubscribeCallback(ctx context.Context, subscribable Subscribable, subscriber string, ...) error
- type Cache
- type CombinedTags
- type Emitter
- type Indexable
- type Publisher
- type PublisherFunc
- type Subscribable
- type TagMap
- type Tags
Constants ¶
const ( EventTypeKey = "EventType" EventIDKey = "EventID" MessageTypeKey = "MessageType" TxTypeKey = "TxType" TxHashKey = "TxHash" HeightKey = "Height" IndexKey = "Index" NameKey = "Name" PermissionKey = "Permission" StackDepthKey = "StackDepth" AddressKey = "Address" OriginKey = "Origin" CalleeKey = "Callee" CallerKey = "Caller" ValueKey = "Value" GasKey = "Gas" ExceptionKey = "Exception" LogNKeyPrefix = "Log" )
const DefaultEventBufferCapacity = 2 << 10
const SubscribeCallbackTimeout = 2 * time.Second
Variables ¶
This section is empty.
Functions ¶
func GenerateSubscriptionID ¶ added in v0.18.0
func LogNTextKey ¶ added in v0.19.0
func PublishAll ¶ added in v0.18.0
func QueryForEventID ¶ added in v0.18.0
Get a query that matches events with a specific eventID
func SubscribeCallback ¶ added in v0.18.0
func SubscribeCallback(ctx context.Context, subscribable Subscribable, subscriber string, queryable query.Queryable, callback func(message interface{}) (stop bool)) error
Subscribe to messages matching query and launch a goroutine to run a callback for each one. The goroutine will exit if the callback returns true for 'stop' and clean up the subscription and channel.
Types ¶
type Cache ¶ added in v0.18.0
type Cache struct {
// contains filtered or unexported fields
}
A Cache buffers events for a Publisher.
func NewCache ¶ added in v0.19.0
func NewCache() *Cache
Create a new Cache with an EventSwitch as backend
type CombinedTags ¶ added in v0.19.0
type CombinedTags []Tags
func (CombinedTags) Get ¶ added in v0.19.0
func (ct CombinedTags) Get(key string) (value string, ok bool)
func (CombinedTags) Keys ¶ added in v0.19.0
func (ct CombinedTags) Keys() []string
func (CombinedTags) Len ¶ added in v0.19.0
func (ct CombinedTags) Len() (length int)
func (CombinedTags) Map ¶ added in v0.19.0
func (ct CombinedTags) Map() map[string]interface{}
type Emitter ¶ added in v0.18.0
type Emitter interface {
Subscribable
Publisher
process.Process
}
func NewEmitter ¶ added in v0.18.0
type Indexable ¶ added in v0.19.0
type Indexable interface {
ProvideIndex(index uint64)
}
If message implement this interface we will provide them with an index in the cache
type PublisherFunc ¶ added in v0.19.0
type Subscribable ¶ added in v0.18.0
type Subscribable interface {
// Subscribe to all events matching query, which is a valid tmlibs Query. Blocking the out channel blocks the entire
// pubsub.
Subscribe(ctx context.Context, subscriber string, queryable query.Queryable, out chan<- interface{}) error
// Unsubscribe subscriber from a specific query string. Note the subscribe channel must be drained.
Unsubscribe(ctx context.Context, subscriber string, queryable query.Queryable) error
UnsubscribeAll(ctx context.Context, subscriber string) error
}
TODO: manage the creation, closing, and draining of channels behind the interface rather than only closing. stop one subscriber from blocking everything!