Documentation ¶
Index ¶
- func WithBlockEvents() options.Opt
- func WithConnectionEvent(value chan *dispatcher.ConnectionEvent) options.Opt
- func WithMaxConnectAttempts(value uint) options.Opt
- func WithMaxReconnectAttempts(value uint) options.Opt
- func WithReconnect(value bool) options.Opt
- func WithReconnectInitialDelay(value time.Duration) options.Opt
- func WithResponseTimeout(value time.Duration) options.Opt
- func WithTimeBetweenConnectAttempts(value time.Duration) options.Opt
- type Client
- func (c *Client) Close()
- func (c *Client) CloseIfIdle() bool
- func (c *Client) Connect() error
- func (c *Client) ConnectionState() ConnectionState
- func (p *Client) PermitBlockEvents()
- func (c *Client) RegisterBlockEvent(filter ...fab.BlockFilter) (fab.Registration, <-chan *fab.BlockEvent, error)
- func (c *Client) SetAfterConnectHandler(h handler)
- func (c *Client) SetBeforeReconnectHandler(h handler)
- func (p *Client) SetConnectEventCh(value chan *dispatcher.ConnectionEvent)
- func (p *Client) SetEventConsumerBufferSize(value uint)
- func (p *Client) SetMaxConnectAttempts(value uint)
- func (p *Client) SetMaxReconnectAttempts(value uint)
- func (p *Client) SetReconnect(value bool)
- func (p *Client) SetReconnectInitialDelay(value time.Duration)
- func (p *Client) SetResponseTimeout(value time.Duration)
- func (p *Client) SetTimeBetweenConnectAttempts(value time.Duration)
- func (c *Client) Stopped() bool
- type ConnectionState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBlockEvents ¶
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 ¶
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 ¶
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 ¶
WithReconnect indicates whether the client should automatically attempt to reconnect to the server after a connection has been lost
func WithReconnectInitialDelay ¶
WithReconnectInitialDelay sets the initial delay before attempting to reconnect.
func WithResponseTimeout ¶
WithResponseTimeout sets the timeout when waiting for a response from the event server
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 ¶
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 ¶
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 (*Client) SetResponseTimeout ¶
func (*Client) SetTimeBetweenConnectAttempts ¶
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