client

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBlockEvents

func WithBlockEvents() options.Opt

WithBlockEvents indicates that block events are to be received. Note that the caller must have sufficient privileges for this option.

func WithConnectionEvent

func WithConnectionEvent(value chan *dispatcher.ConnectionEvent) options.Opt

WithConnectionEvent sets the channel that is to receive connection events, i.e. when the client connects and/or disconnects from the channel event service.

func WithMaxConnectAttempts

func WithMaxConnectAttempts(value uint) options.Opt

WithMaxConnectAttempts sets the maximum number of times that the client will attempt to connect to the server. If set to 0 then the client will try until it is stopped.

func WithMaxReconnectAttempts

func WithMaxReconnectAttempts(value uint) options.Opt

WithMaxReconnectAttempts sets the maximum number of times that the client will attempt to reconnect to the server after a connection has been lost. If set to 0 then the client will try until it is stopped.

func WithReconnect

func WithReconnect(value bool) options.Opt

WithReconnect indicates whether the client should automatically attempt to reconnect to the server after a connection has been lost

func WithReconnectInitialDelay

func WithReconnectInitialDelay(value time.Duration) options.Opt

WithReconnectInitialDelay sets the initial delay before attempting to reconnect.

func WithResponseTimeout

func WithResponseTimeout(value time.Duration) options.Opt

WithResponseTimeout sets the timeout when waiting for a response from the event server

func WithTimeBetweenConnectAttempts

func WithTimeBetweenConnectAttempts(value time.Duration) options.Opt

WithTimeBetweenConnectAttempts sets the time between connection attempts.

Types

type Client

type Client struct {
	*eventservice.Service

	sync.RWMutex
	// contains filtered or unexported fields
}

Client connects to an event server and receives events, such as block, filtered block, chaincode, and transaction status events. Client also monitors the connection to the event server and attempts to reconnect if the connection is closed.

func New

func New(dispatcher eventservice.Dispatcher, opts ...options.Opt) *Client

New returns a new event client

func (*Client) Close

func (c *Client) Close()

Close closes the connection to the event server and releases all resources. Once this function is invoked the client may no longer be used.

func (*Client) CloseIfIdle

func (c *Client) CloseIfIdle() bool

CloseIfIdle closes the connection to the event server only if there are no outstanding registrations. Returns true if the client was closed. In this case the client may no longer be used. A return value of false indicates that the client could not be closed since there was at least one registration.

func (*Client) Connect

func (c *Client) Connect() error

Connect connects to the peer and registers for events on a particular channel.

func (*Client) ConnectionState

func (c *Client) ConnectionState() ConnectionState

ConnectionState returns the connection state

func (*Client) PermitBlockEvents

func (p *Client) PermitBlockEvents()

func (*Client) RegisterBlockEvent

func (c *Client) RegisterBlockEvent(filter ...fab.BlockFilter) (fab.Registration, <-chan *fab.BlockEvent, error)

RegisterBlockEvent registers for block events. If the client is not authorized to receive block events then an error is returned.

func (*Client) SetAfterConnectHandler

func (c *Client) SetAfterConnectHandler(h handler)

SetAfterConnectHandler registers a handler that is called after the client connects to the event server. This allows for custom code to be executed for a particular event client implementation.

func (*Client) SetBeforeReconnectHandler

func (c *Client) SetBeforeReconnectHandler(h handler)

SetBeforeReconnectHandler registers a handler that will be called before retrying to reconnect to the event server. This allows for custom code to be executed for a particular event client implementation.

func (*Client) SetConnectEventCh

func (p *Client) SetConnectEventCh(value chan *dispatcher.ConnectionEvent)

func (*Client) SetEventConsumerBufferSize

func (p *Client) SetEventConsumerBufferSize(value uint)

func (*Client) SetMaxConnectAttempts

func (p *Client) SetMaxConnectAttempts(value uint)

func (*Client) SetMaxReconnectAttempts

func (p *Client) SetMaxReconnectAttempts(value uint)

func (*Client) SetReconnect

func (p *Client) SetReconnect(value bool)

func (*Client) SetReconnectInitialDelay

func (p *Client) SetReconnectInitialDelay(value time.Duration)

func (*Client) SetResponseTimeout

func (p *Client) SetResponseTimeout(value time.Duration)

func (*Client) SetTimeBetweenConnectAttempts

func (p *Client) SetTimeBetweenConnectAttempts(value time.Duration)

func (*Client) Stopped

func (c *Client) Stopped() bool

Stopped returns true if the client has been stopped (disconnected) and is no longer usable.

func (*Client) TransferRegistrations

func (c *Client) TransferRegistrations(close bool) (fab.EventSnapshot, error)

TransferRegistrations transfers all registrations into an EventSnapshot. The registrations are not closed and may susequently be transferred to a new event client. - close - if true then the client will also be closed

type ConnectionState

type ConnectionState int32

ConnectionState is the state of the client connection

const (
	// Disconnected indicates that the client is disconnected from the server
	Disconnected ConnectionState = iota
	// Connecting indicates that the client is in the process of establishing a connection
	Connecting
	// Connected indicates that the client is connected to the server
	Connected
)

func (ConnectionState) String

func (s ConnectionState) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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