api

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathApiV1KV       = "/api/kv/v1"
	PathApiV1KVSearch = "/api/kv/search/v1"
	PathApiV1KVList   = "/api/kv/list/v1"
)
View Source
const (
	EventKVGet event.Id = iota + 1
	EventKVSet
	EventKVDel
	EventKVWatch
	EventKVUnWatch
	EventKVWatchValue
)
View Source
const (
	AuthTokenHeaderName = "x-loop-auth"
)
View Source
const (
	PathApiV1Watch = "/api/watch/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key, value string) error
	Delete(ctx context.Context, key string) error
	Search(ctx context.Context, prefix string) ([]EntityKV, error)
	List(ctx context.Context, prefix string) ([]EntityKV, error)
}

func NewKV

func NewKV(c *Config) (Client, error)

type Config

type Config struct {
	SSL       bool
	HostPort  string
	AuthToken string
}

func (Config) Validate

func (v Config) Validate() error

type EntitiesKV added in v0.1.1

type EntitiesKV []EntityKV

func (EntitiesKV) MarshalEasyJSON added in v0.1.1

func (v EntitiesKV) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntitiesKV) MarshalJSON added in v0.1.1

func (v EntitiesKV) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EntitiesKV) UnmarshalEasyJSON added in v0.1.1

func (v *EntitiesKV) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntitiesKV) UnmarshalJSON added in v0.1.1

func (v *EntitiesKV) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type EntityKV added in v0.1.1

type EntityKV struct {
	Key string  `json:"k"`
	Val *string `json:"v"`
}

func (EntityKV) MarshalEasyJSON added in v0.1.1

func (v EntityKV) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntityKV) MarshalJSON added in v0.1.1

func (v EntityKV) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EntityKV) UnmarshalEasyJSON added in v0.1.1

func (v *EntityKV) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntityKV) UnmarshalJSON added in v0.1.1

func (v *EntityKV) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (EntityKV) Value added in v0.1.1

func (v EntityKV) Value() string

func (EntityKV) ValueStrOrNull added in v0.1.1

func (v EntityKV) ValueStrOrNull() string

type Watch added in v0.1.1

type Watch interface {
	Open() error
	AfterOpened(call func())
	Close()
	AfterClosed(call func())
	KeyHandler(call func(e EntitiesKV))
	KeySubscribe(keys ...string)
}

func NewWatch added in v0.1.1

func NewWatch(ctx context.Context, c *Config, l xlog.Logger) (Watch, error)

Jump to

Keyboard shortcuts

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