mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 06:31:57 +00:00
rpc/client: add Events method to the client interface (#7982)
- Update documentation to deprecate the old methods. - Add Events methods to HTTP, WS, and Local clients. - Add Events method to the light client wrapper. - Rename legacy events client to SubscriptionClient.
This commit is contained in:
+33
-10
@@ -37,14 +37,16 @@ type Client interface {
|
||||
Start(context.Context) error
|
||||
|
||||
// These embedded interfaces define the callable methods of the service.
|
||||
|
||||
ABCIClient
|
||||
EventsClient
|
||||
EvidenceClient
|
||||
HistoryClient
|
||||
MempoolClient
|
||||
NetworkClient
|
||||
SignClient
|
||||
StatusClient
|
||||
EvidenceClient
|
||||
MempoolClient
|
||||
SubscriptionClient
|
||||
}
|
||||
|
||||
// ABCIClient groups together the functionality that principally affects the
|
||||
@@ -119,20 +121,41 @@ type NetworkClient interface {
|
||||
Health(context.Context) (*coretypes.ResultHealth, error)
|
||||
}
|
||||
|
||||
// EventsClient is reactive, you can subscribe to any message, given the proper
|
||||
// string. see tendermint/types/events.go
|
||||
// EventsClient exposes the methods to retrieve events from the consensus engine.
|
||||
type EventsClient interface {
|
||||
// Subscribe subscribes given subscriber to query. Returns a channel with
|
||||
// cap=1 onto which events are published. An error is returned if it fails to
|
||||
// subscribe. outCapacity can be used optionally to set capacity for the
|
||||
// channel. Channel is never closed to prevent accidental reads.
|
||||
// Events fetches a batch of events from the server matching the given query
|
||||
// and time range.
|
||||
Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)
|
||||
}
|
||||
|
||||
// TODO(creachadair): This interface should be removed once the streaming event
|
||||
// interface is removed in Tendermint v0.37.
|
||||
type SubscriptionClient interface {
|
||||
// Subscribe issues a subscription request for the given subscriber ID and
|
||||
// query. This method does not block: If subscription fails, it reports an
|
||||
// error, and if subscription succeeds it returns a channel that delivers
|
||||
// matching events until the subscription is stopped. The channel is never
|
||||
// closed; the client is responsible for knowing when no further data will
|
||||
// be sent.
|
||||
//
|
||||
// ctx cannot be used to unsubscribe. To unsubscribe, use either Unsubscribe
|
||||
// or UnsubscribeAll.
|
||||
// The context only governs the initial subscription, it does not control
|
||||
// the lifetime of the channel. To cancel a subscription call Unsubscribe or
|
||||
// UnsubscribeAll.
|
||||
//
|
||||
// Deprecated: This method will be removed in Tendermint v0.37, use Events
|
||||
// instead.
|
||||
Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error)
|
||||
|
||||
// Unsubscribe unsubscribes given subscriber from query.
|
||||
//
|
||||
// Deprecated: This method will be removed in Tendermint v0.37, use Events
|
||||
// instead.
|
||||
Unsubscribe(ctx context.Context, subscriber, query string) error
|
||||
|
||||
// UnsubscribeAll unsubscribes given subscriber from all the queries.
|
||||
//
|
||||
// Deprecated: This method will be removed in Tendermint v0.37, use Events
|
||||
// instead.
|
||||
UnsubscribeAll(ctx context.Context, subscriber string) error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user