client

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 44 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultAgentHost defines default host address for agent.
	DefaultAgentHost = "127.0.0.1"
	// DefaultPortGRPC defines default port for GRPC connection.
	DefaultPortGRPC = 9111
	// DefaultPortHTTP defines default port for HTTP connection.
	DefaultPortHTTP = 9191
)

Variables

This section is empty.

Functions

func ErrorConnectionFailed

func ErrorConnectionFailed(host string) error

ErrorConnectionFailed returns an error with host in the error message when connection to agent failed.

func IsErrConnectionFailed

func IsErrConnectionFailed(err error) bool

IsErrConnectionFailed returns true if the error is caused by connection failed.

func ParseHostURL

func ParseHostURL(host string) (*url.URL, error)

ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL

Types

type APIClient

type APIClient interface {
	InfraAPIClient
	ModelAPIClient
	SchedulerAPIClient
	VppAPIClient
	MetricsAPIClient

	ConfigClient() (client.ConfigClient, error)

	AgentHost() string
	Version() string
	KVDBClient() (KVDBAPIClient, error)
	GRPCConn() (*grpc.ClientConn, error)
	HTTPClient() *http.Client
	ServerVersion(ctx context.Context) (types.Version, error)
	NegotiateAPIVersion(ctx context.Context)
	NegotiateAPIVersionPing(types.Ping)
	Close() error
}

APIClient is an interface that clients that talk with a agent server must implement.

type Client

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

Client is the API client that performs all operations against a Ligato agent.

func NewClient

func NewClient(host string) (*Client, error)

NewClient returns client with host option.

func NewClientWithOpts

func NewClientWithOpts(ops ...Opt) (*Client, error)

NewClientWithOpts returns client with ops applied.

func (*Client) AgentHost

func (c *Client) AgentHost() string

func (*Client) Close

func (c *Client) Close() error

Close the transport used by the client

func (*Client) ConfigClient

func (c *Client) ConfigClient() (client.ConfigClient, error)

ConfigClient returns "remoteclient" with gRPC connection.

func (*Client) GRPCConn

func (c *Client) GRPCConn() (*grpc.ClientConn, error)

GRPCConn returns configured gRPC client.

func (*Client) GetMetricData

func (c *Client) GetMetricData(ctx context.Context, metricName string) (map[string]interface{}, error)

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns configured HTTP client.

func (*Client) KVDBClient

func (c *Client) KVDBClient() (KVDBAPIClient, error)

KVDBClient returns configured KVDB client.

func (*Client) LoggerList

func (c *Client) LoggerList(ctx context.Context) ([]types.Logger, error)

func (*Client) LoggerSet

func (c *Client) LoggerSet(ctx context.Context, logger, level string) error

func (*Client) ModelList

func (c *Client) ModelList(ctx context.Context, opts types.ModelListOptions) ([]types.Model, error)

func (*Client) NegotiateAPIVersion

func (c *Client) NegotiateAPIVersion(ctx context.Context)

func (*Client) NegotiateAPIVersionPing

func (c *Client) NegotiateAPIVersionPing(p types.Ping)

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (types.Ping, error)

Ping pings the server and returns the value of the "API-Version" headers.

func (*Client) SchedulerDump

func (c *Client) SchedulerDump(ctx context.Context, opts types.SchedulerDumpOptions) ([]api.KVWithMetadata, error)

func (*Client) SchedulerValues

func (c *Client) SchedulerValues(ctx context.Context, opts types.SchedulerValuesOptions) ([]*kvscheduler.BaseValueStatus, error)

func (*Client) ServerVersion

func (c *Client) ServerVersion(ctx context.Context) (types.Version, error)

ServerVersion returns information of the client and agent host.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*probe.ExposedStatus, error)

func (*Client) Version

func (c *Client) Version() string

func (*Client) VppRunCli

func (c *Client) VppRunCli(ctx context.Context, cmd string) (reply string, err error)

type InfraAPIClient

type InfraAPIClient interface {
	Status(ctx context.Context) (*probe.ExposedStatus, error)
	Ping(ctx context.Context) (types.Ping, error)
	LoggerList(ctx context.Context) ([]types.Logger, error)
	LoggerSet(ctx context.Context, logger, level string) error
}

SystemAPIClient defines API client methods for the system

type KVDBAPIClient

type KVDBAPIClient interface {
	keyval.CoreBrokerWatcher
	ProtoBroker() keyval.ProtoBroker
	CompleteFullKey(key string) (string, error)
}

type KVDBClient

type KVDBClient struct {
	keyval.CoreBrokerWatcher
	// contains filtered or unexported fields
}

KVDBClient provides client access to the KVDB server.

func NewKVDBClient

func NewKVDBClient(kvdb keyval.CoreBrokerWatcher, serviceLabel string) *KVDBClient

func (*KVDBClient) CompleteFullKey

func (k *KVDBClient) CompleteFullKey(key string) (string, error)

func (*KVDBClient) Delete

func (k *KVDBClient) Delete(key string, opts ...datasync.DelOption) (existed bool, err error)

func (*KVDBClient) GetValue

func (k *KVDBClient) GetValue(key string) (data []byte, found bool, revision int64, err error)

func (*KVDBClient) ListKeys

func (k *KVDBClient) ListKeys(prefix string) (keyval.BytesKeyIterator, error)

func (*KVDBClient) ListValues

func (k *KVDBClient) ListValues(prefix string) (keyval.BytesKeyValIterator, error)

func (*KVDBClient) ProtoBroker

func (k *KVDBClient) ProtoBroker() keyval.ProtoBroker

ProtoBroker returns ProtoWrapper with JSON serializer for KVDB connection.

func (*KVDBClient) Put

func (k *KVDBClient) Put(key string, data []byte, opts ...datasync.PutOption) (err error)

type MetricsAPIClient

type MetricsAPIClient interface {
	GetMetricData(ctx context.Context, metricName string) (map[string]interface{}, error)
}

type ModelAPIClient

type ModelAPIClient interface {
	ModelList(ctx context.Context, opts types.ModelListOptions) ([]types.Model, error)
}

ModelAPIClient defines API client methods for the models

type Opt

type Opt func(*Client) error

func WithAPIVersionNegotiation

func WithAPIVersionNegotiation() Opt

WithAPIVersionNegotiation enables automatic API version negotiation for the client. With this option enabled, the client automatically negotiates the API version to use when making requests. API version negotiation is performed on the first request; subsequent requests will not re-negotiate.

func WithEtcdDialTimeout

func WithEtcdDialTimeout(t time.Duration) Opt

WithEtcdDialTimeout overrides dial timeout for KVDB (etcd) connection.

func WithEtcdEndpoints

func WithEtcdEndpoints(endpoints []string) Opt

WithEtcdEndpoints overrides endpoints for KVDB (etcd) connection.

func WithGRPCClient

func WithGRPCClient(client *grpc.ClientConn) Opt

WithGRPCClient overrides the grpc client with the specified one

func WithGrpcPort

func WithGrpcPort(p int) Opt

WithGrpcPort overrides port for GRPC connection.

func WithGrpcTLS

func WithGrpcTLS(cert, key, ca string, skipVerify bool) Opt

WithGrpcTLS adds tls.Config for gRPC to Client.

func WithHTTPBasicAuth

func WithHTTPBasicAuth(s string) Opt

WithHTTPBasicAuth adds basic auth header to HTTP headers.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Opt

WithHTTPClient overrides the http client with the specified one

func WithHTTPHeader

func WithHTTPHeader(k, v string) Opt

WithHTTPHeader adds header to HTTP headers.

func WithHTTPPort

func WithHTTPPort(p int) Opt

WithHTTPPort overrides port for HTTP connection.

func WithHTTPTLS

func WithHTTPTLS(cert, key, ca string, skipVerify bool) Opt

WithHTTPTLS adds tls.Config for HTTP to Client.

func WithHost

func WithHost(host string) Opt

WithHost overrides the client host with the specified one.

func WithKvdbTLS

func WithKvdbTLS(cert, key, ca string, skipVerify bool) Opt

WithKvdbTLS adds tls.Config for KVDB to Client.

func WithServiceLabel

func WithServiceLabel(label string) Opt

func WithTimeout

func WithTimeout(timeout time.Duration) Opt

WithTimeout configures the time limit for requests made by the HTTP client

func WithVersion

func WithVersion(version string) Opt

WithVersion overrides the client version with the specified one. If an empty version is specified, the value will be ignored to allow version negotiation.

type SchedulerAPIClient

type SchedulerAPIClient interface {
	SchedulerDump(ctx context.Context, opts types.SchedulerDumpOptions) ([]api.KVWithMetadata, error)
	SchedulerValues(ctx context.Context, opts types.SchedulerValuesOptions) ([]*kvscheduler.BaseValueStatus, error)
}

SchedulerAPIClient defines API client methods for the scheduler

type VppAPIClient

type VppAPIClient interface {
	VppRunCli(ctx context.Context, cmd string) (reply string, err error)
}

VppAPIClient defines API client methods for the VPP

Directories

Path Synopsis
Package tlsconfig provides more convenient way to create "tls.Config".
Package tlsconfig provides more convenient way to create "tls.Config".

Jump to

Keyboard shortcuts

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