Documentation ¶
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) GetKeys(ctx context.Context, source string) ([]string, error)
- func (c *Client) GetSources(ctx context.Context) ([]string, error)
- func (c *Client) GetValue(ctx context.Context, source string, key string) ([]byte, error)
- func (c *Client) Join(ctx context.Context, address string) error
- func (c *Client) RemoveSource(ctx context.Context, source string) error
- func (c *Client) RemoveValue(ctx context.Context, source string, key string) error
- func (c *Client) SetValue(ctx context.Context, source string, key string, value []byte) error
- func (c *Client) Subscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.SubscribeResponse, error)
- func (c *Client) SubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.SubscribeKeyResponse, error)
- func (c *Client) Unsubscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.UnsubscribeResponse, error)
- func (c *Client) UnsubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.UnsubscribeKeyResponse, error)
- type UpdateHandler
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for communicating with an Iris server
func NewClient ¶
NewClient returns a new Iris GRPC client for the given server address. The client's Close method should be called when the returned client is no longer needed.
Example ¶
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) defer cancel() testClient, err := NewClient(ctx, "127.0.0.1:32000", nil) if err != nil { //handle connection error return } defer testClient.Close()
Output:
func NewTLSClient ¶
func NewTLSClient(ctx context.Context, serverAddress string, serverName string, cert string, privateKey string, certificateAuthority string) (*Client, error)
NewTLSClient returns a new Iris GRPC client for the given server address. You must provide paths to a certificate authority, client certificate, and client private key. You must also provide a value for server name that matches the common name in the certificate of the server you are connecting to. The client's Close method should be called when the returned client is no longer needed.
Example ¶
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) defer cancel() testClient, err := NewTLSClient(ctx, "127.0.0.1:32000", iris.DefaultServerName, "/path/to/client.crt", "/path/to/client.key", "/path/to/ca.crt") if err != nil { //handle connection error return } defer testClient.Close()
Output:
func (*Client) GetKeys ¶
GetKeys expects a source and responds with an array of strings representing the available keys
func (*Client) GetSources ¶
GetSources responds with an array of strings representing sources
func (*Client) RemoveSource ¶
RemoveSource removes the specified source and all its values from the server
func (*Client) RemoveValue ¶
RemoveValue expects a source and key and removes that entry from the source
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.SubscribeResponse, error)
Subscribe indicates that the client wishes to be notified of all updates for the specified source
func (*Client) SubscribeKey ¶
func (c *Client) SubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.SubscribeKeyResponse, error)
SubscribeKey indicates that the client wishes to be notified of updates associated with a specific key from the specified source
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.UnsubscribeResponse, error)
Unsubscribe indicates that the client no longer wishes to be notified of updates for the specified source
func (*Client) UnsubscribeKey ¶
func (c *Client) UnsubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.UnsubscribeKeyResponse, error)
UnsubscribeKey indicates that the client no longer wishes to be notified of updates associated with a specific key from the specified source
type UpdateHandler ¶
UpdateHandler descibes a function used for handling values received by the client