subscriber

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ConnectionIdAttr is the key of the Neutron's custom message event's attribute that contains the
	// connectionID of the event's ActiveQuery.
	ConnectionIdAttr = eventTypePrefix + "." + types.AttributeKeyConnectionID
	// QueryIdAttr is the key of the Neutron's custom message event's attribute that contains the
	// incoming ICQ ID.
	QueryIdAttr = eventTypePrefix + "." + types.AttributeKeyQueryID
	// KvKeyAttr is the key of the Neutron's custom message event's attribute that contains the KV
	// values for the incoming KV ICQ.
	KvKeyAttr = eventTypePrefix + "." + types.AttributeKeyKVQuery
	// TransactionsFilterAttr is the key of the Neutron's custom message event's attribute that
	// contains the transaction filter value for the incoming TX ICQ.
	TransactionsFilterAttr = eventTypePrefix + "." + types.AttributeTransactionsFilterQuery
	// TypeAttr is the key of the Neutron's custom message event's attribute that contains the type
	// of the incoming ICQ.
	TypeAttr = eventTypePrefix + "." + types.AttributeKeyQueryType
	// OwnerAttr is the key of the Neutron's custom message event's attribute that contains the
	// address of the ICQ owner.
	OwnerAttr = eventTypePrefix + "." + types.AttributeKeyOwner
)

types of keys for parsing incoming events

Variables

This section is empty.

Functions

func NewDefaultSubscriber added in v0.3.0

func NewDefaultSubscriber(cfg config.NeutronQueryRelayerConfig, logRegistry *nlogger.Registry) (relay.Subscriber, error)

func NewRESTClient added in v0.3.0

func NewRESTClient(restAddr string, timeout time.Duration) (*restclient.HTTPAPIConsole, error)

NewRESTClient makes sure that the restAddr is formed correctly and returns a REST query.

Types

type Config added in v0.3.0

type Config struct {
	// ConnectionID is the Neutron's side connection ID used to filter out queries.
	ConnectionID string
	// WatchedTypes is the list of query types to be observed and handled.
	WatchedTypes []neutrontypes.InterchainQueryType
	// Registry is a watch list registry. It contains a list of addresses and a list of queryIDs, and the Subscriber only
	// works with interchain queries and events that are under ownership of these addresses and match the queryIDs.
	Registry *rg.Registry
}

Config contains configurable fields for the Subscriber.

type RestHttpQuery added in v0.3.0

type RestHttpQuery interface {
	NeutronInterchainQueriesRegisteredQuery(params *query.NeutronInterchainQueriesRegisteredQueryParams, opts ...query.ClientOption) (*query.NeutronInterchainQueriesRegisteredQueryOK, error)
	NeutronInterchainQueriesRegisteredQueries(params *query.NeutronInterchainQueriesRegisteredQueriesParams, opts ...query.ClientOption) (*query.NeutronInterchainQueriesRegisteredQueriesOK, error)
}

type RpcHttpClient added in v0.3.0

type RpcHttpClient interface {
	Start() error
	Subscribe(ctx context.Context, subscriber string, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
	Status(ctx context.Context) (*ctypes.ResultStatus, error)
	Unsubscribe(ctx context.Context, subscriber, query string) error
}

func NewRPCClient added in v0.3.0

func NewRPCClient(rpcAddr string, timeout time.Duration) (RpcHttpClient, error)

NewRPCClient creates a new tendermint RPC client with timeout.

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber is responsible for subscribing on chain's ICQ events. It parses incoming events, filters them in accordance with the Registry configuration and watchedTypes, and provides a stream of split to KV and TX messages.

func NewSubscriber

func NewSubscriber(
	cfg *Config,
	rpcClient RpcHttpClient,
	restClient RestHttpQuery,
	logger *zap.Logger,
) (*Subscriber, error)

NewSubscriber creates a new Subscriber instance ready to subscribe to Neutron events.

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(ctx context.Context, tasks chan neutrontypes.RegisteredQuery) error

Subscribe subscribes to 3 types of events: 1. a new block was created, 2. a query was updated (created / updated), 3. a query was removed.

Directories

Path Synopsis
querier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL