client

package
v0.0.0-...-6dd9c4d Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultName      = "xconf"
	DefaultNamespace = "x"
)

Variables

View Source
var (
	// ErrNotFound is the error returned by file not exists
	ErrNotFound = errors.New("not found")
)

Functions

func SliceIndex

func SliceIndex(limit int, predicate func(i int) bool) int

Types

type File

type File struct {
	Group   string
	Name    string
	Content []byte
	Version int64
	Meta    Metadata
}

type Metadata

type Metadata struct {
	CreateTime int64  `json:"createTime"`
	UpdateTime int64  `json:"updateTime"`
	Canary     string `json:"canary"`
}

type OnChange

type OnChange func(*File) error

type Options

type Options struct {
	ID        string   `json:"id"`
	Endpoints []string `json:"endpoints"`
	Username  string   `json:"username"`
	Password  string   `json:"password"`
	Namespace string   `json:"namespace"`
	CacheDir  string   `json:"cache-dir"`
}

type Xconf

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

func New

func New(opt *Options) *Xconf

func (*Xconf) CheckCanary

func (c *Xconf) CheckCanary(canary string) bool

func (*Xconf) Get

func (c *Xconf) Get(ctx context.Context, key string) ([]byte, int64, error)

func (*Xconf) GetConfig

func (c *Xconf) GetConfig(ctx context.Context, group, name string) (data []byte, err error)

func (*Xconf) Key

func (c *Xconf) Key(group, name string) string

func (*Xconf) Meta

func (c *Xconf) Meta(key string) string

func (*Xconf) ReadCache

func (c *Xconf) ReadCache(group, name string) ([]byte, error)

func (*Xconf) Watch

func (c *Xconf) Watch(ctx context.Context, group, name string, h OnChange) error

func (*Xconf) WriteCache

func (c *Xconf) WriteCache(group, name string, content []byte) error

Jump to

Keyboard shortcuts

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