Documentation
¶
Index ¶
- Constants
- Variables
- func ReadBody(resp *http.Response) []byte
- type Client
- func (c *Client) Create(ctx context.Context, kv KVRequest, opts ...OpOption) (*KVDoc, error)
- func (c *Client) CurrentRevision() int
- func (c *Client) Delete(ctx context.Context, kvID string, opts ...OpOption) error
- func (c *Client) List(ctx context.Context, opts ...GetOption) (*KVResponse, int, error)
- func (c *Client) Put(ctx context.Context, kv KVRequest, opts ...OpOption) (*KVDoc, error)
- type Config
- type GetOption
- type GetOptions
- type KVDoc
- type KVRequest
- type KVResponse
- type LabelDocResponse
- type OpOption
- type OpOptions
Constants ¶
View Source
const ( QueryParamQ = "q" QueryByLabelsCon = "&" QueryParamMatch = "match" QueryParamKeyID = "kv_id" )
match mode
View Source
const ( HeaderRevision = "X-Kie-Revision" HeaderContentType = "Content-Type" )
http headers
View Source
const ( APIPathKV = "kie/kv" MsgOpFailed = "operation failed" FmtOpFailed = "operate failed [%s], http status [%s], body [%s]" APIFmt = "%s/%s/%s/%s/%s" )
const
View Source
const (
ContentTypeJSON = "application/json"
)
ContentType
Variables ¶
View Source
var ( ErrKeyNotExist = errors.New("can not find value") ErrIDEmpty = errors.New("id is empty") ErrNoChanges = errors.New("kv has not been changed since last polling") )
client errors
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the servicecomb kie rest client. it is concurrency safe
func (*Client) CurrentRevision ¶
CurrentRevision return the current revision of kie, which is updated on the last get request
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 WithGetProject ¶
WithGetProject query keys with certain project
func WithRevision ¶
WithRevision query keys with certain revision
type GetOptions ¶
type GetOptions struct { Labels []map[string]string Project string Key string Wait string Exact bool Revision string }
GetOptions is the options of client func
type KVDoc ¶
type KVDoc struct { ID string `json:"id,omitempty" bson:"id,omitempty" yaml:"id,omitempty" swag:"string"` Key string `json:"key" yaml:"key"` Value string `json:"value,omitempty" yaml:"value,omitempty"` ValueType string `json:"value_type,omitempty" bson:"value_type,omitempty" yaml:"value_type,omitempty"` //ini,json,text,yaml,properties Checker string `json:"check,omitempty" yaml:"check,omitempty"` //python script CreateRevision int64 `json:"create_revision,omitempty" bson:"create_revision," yaml:"create_revision,omitempty"` UpdateRevision int64 `json:"update_revision,omitempty" bson:"update_revision," yaml:"update_revision,omitempty"` Project string `json:"project,omitempty" yaml:"project,omitempty"` Status string `json:"status,omitempty" yaml:"status,omitempty"` CreatTime int64 `json:"create_time,omitempty" yaml:"create_time,omitempty"` UpdateTime int64 `json:"update_time,omitempty" yaml:"update_time,omitempty"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` //redundant Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` //redundant }
KVDoc is database struct to store kv
type KVRequest ¶
type KVRequest struct { ID string `json:"id" yaml:"id"` Key string `json:"key" yaml:"key"` Value string `json:"value,omitempty" yaml:"value,omitempty"` Status string `json:"status,omitempty" yaml:"status,omitempty"` ValueType string `json:"value_type,omitempty" bson:"value_type,omitempty" yaml:"value_type,omitempty"` //ini,json,text,yaml,properties Checker string `json:"check,omitempty" yaml:"check,omitempty"` //python script Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` //redundant }
KVRequest is http request body
type KVResponse ¶
type KVResponse struct { LabelDoc *LabelDocResponse `json:"label,omitempty"` Total int `json:"total,omitempty"` Data []*KVDoc `json:"data,omitempty"` }
KVResponse represents the key value list
type LabelDocResponse ¶
LabelDocResponse is label struct
Click to show internal directories.
Click to hide internal directories.