api

package
v0.0.0-...-53d447e Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

README

Iris Client

This package can be used to communicate with an Iris server using the gRPC protocol and the Go programming language. For usage examples, see the included example_test.go.

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.

func NewClient(ctx context.Context, serverAddress string, opts []grpc.DialOption) (*Client, error)

NewTLSClient

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.

NewTLSClient(ctx context.Context, serverAddress string, serverName string, cert string, privateKey string, certificateAuthority string) (*Client, error)

Close

Close tears down the client's underlying connections

func (c *Client) Close() error

Join

Join the node reachable at the address to this cluster

func (c *Client) Join(ctx context.Context, address string) error

GetSources

GetSources responds with an array of strings representing sources

func (c *Client) GetSources(ctx context.Context) ([]string, error)

GetKeys

GetKeys expects a source and responds with an array of strings representing the available keys

func (c *Client) GetKeys(ctx context.Context, source string) ([]string, error)

SetValue

SetValue sets the value for the specified source and key

func (c *Client) SetValue(ctx context.Context, source string, key string, value []byte) error

GetValue

GetValue expects a source and key and responds with the associated value

func (c *Client) GetValue(ctx context.Context, source string, key string) ([]byte, error)

RemoveValue

RemoveValue expects a source and key and removes that entry from the source

func (c *Client) RemoveValue(ctx context.Context, source string, key string) error

RemoveSource

RemoveSource removes the specified source and all its values from the server

func (c *Client) RemoveSource(ctx context.Context, source string) error

Subscribe

Subscribe indicates that the client wishes to be notified of all updates for the specified source

func (c *Client) Subscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.SubscribeResponse, error)

SubscribeKey

SubscribeKey indicates that the client wishes to be notified of updates associated with a specific key from the specified source

func (c *Client) SubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.SubscribeKeyResponse, error)

Unsubscribe

Unsubscribe indicates that the client no longer wishes to be notified of updates for the specified source

func (c *Client) Unsubscribe(ctx context.Context, source string, handler *UpdateHandler) (*pb.UnsubscribeResponse, error)

UnsubscribeKey

UnsubscribeKey indicates that the client no longer wishes to be notified of updates associated with a specific key from the specified source

func (c *Client) UnsubscribeKey(ctx context.Context, source string, key string, handler *UpdateHandler) (*pb.UnsubscribeKeyResponse, error)

Documentation

Index

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

func NewClient(ctx context.Context, serverAddress string, opts []grpc.DialOption) (*Client, error)

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) Close

func (c *Client) Close() error

Close tears down the client's underlying connections

func (*Client) GetKeys

func (c *Client) GetKeys(ctx context.Context, source string) ([]string, error)

GetKeys expects a source and responds with an array of strings representing the available keys

func (*Client) GetSources

func (c *Client) GetSources(ctx context.Context) ([]string, error)

GetSources responds with an array of strings representing sources

func (*Client) GetValue

func (c *Client) GetValue(ctx context.Context, source string, key string) ([]byte, error)

GetValue expects a source and key and responds with the associated value

func (*Client) Join

func (c *Client) Join(ctx context.Context, address string) error

Join the node reachable at the address to this cluster

func (*Client) RemoveSource

func (c *Client) RemoveSource(ctx context.Context, source string) error

RemoveSource removes the specified source and all its values from the server

func (*Client) RemoveValue

func (c *Client) RemoveValue(ctx context.Context, source string, key string) error

RemoveValue expects a source and key and removes that entry from the source

func (*Client) SetValue

func (c *Client) SetValue(ctx context.Context, source string, key string, value []byte) error

SetValue sets the value for the specified source and key

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

type UpdateHandler func(update *pb.Update)

UpdateHandler descibes a function used for handling values received by the client

Jump to

Keyboard shortcuts

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