client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIPathKV = "kie/kv"
)

const

Variables

View Source
var (
	ErrKeyNotExist = errors.New("can not find value")
)

client errors

Functions

This section is empty.

Types

type Client

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

Client is the servicecomb kie rest client. it is concurrency safe

func New

func New(config Config) (*Client, error)

New create a client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, kvID, labelID string, opts ...OpOption) error

Delete remove kv

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*model.KVResponse, error)

Get get value of a key

func (*Client) Put

func (c *Client) Put(ctx context.Context, kv model.KVDoc, opts ...OpOption) (*model.KVDoc, error)

Put create value of a key

func (*Client) SearchByLabels

func (c *Client) SearchByLabels(ctx context.Context, opts ...GetOption) ([]*model.KVResponse, error)

SearchByLabels get value by lables

type Config

type Config struct {
	Endpoint      string
	DefaultLabels map[string]string
	VerifyPeer    bool //TODO make it works, now just keep it false
}

Config is the config of client

type GetOption

type GetOption func(*GetOptions)

GetOption is the functional option of client func

func WithDepth

func WithDepth(d int) GetOption

WithDepth query keys with partial match query labels

func WithGetProject

func WithGetProject(project string) GetOption

WithGetProject query keys with certain project

func WithLabels

func WithLabels(l ...map[string]string) GetOption

WithLabels query kv by labels

type GetOptions

type GetOptions struct {
	Labels  []map[string]string
	Depth   int
	Project string
}

GetOptions is the options of client func

type OpOption

type OpOption func(*OpOptions)

OpOption is the functional option of client func

func WithProject

func WithProject(project string) OpOption

WithProject set project to param

type OpOptions

type OpOptions struct {
	Project string
}

OpOptions is the options of client func

Jump to

Keyboard shortcuts

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