configstores

package
v0.0.0-...-be1e383 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName = "configStore"
	All         = "*"
)
View Source
const (
	AppId = iota
	Group
	Label
	Key
	Tag
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationItem

type ConfigurationItem struct {
	Key      string
	Content  string
	Group    string
	Label    string
	Tags     map[string]string
	Metadata map[string]string
}

ConfigurationItem represents a configuration item with key, content and other information.

type DeleteRequest

type DeleteRequest struct {
	AppId    string
	Group    string
	Label    string
	Keys     []string
	Metadata map[string]string
}

DeleteRequest is the object describing a delete configuration request

type GetRequest

type GetRequest struct {
	AppId    string
	Group    string
	Label    string
	Keys     []string
	Metadata map[string]string
}

GetRequest is the object describing a get configuration request

type Registry

type Registry interface {
	Register(fs ...*StoreFactory)
	Create(compType string) (Store, error)
}

func NewRegistry

func NewRegistry(info *info.RuntimeInfo) Registry

type SetRequest

type SetRequest struct {
	StoreName string
	AppId     string
	Items     []*ConfigurationItem
}

SetRequest is the object describing a save configuration request

type Store

type Store interface {
	//Init init the configuration store.
	Init(config *StoreConfig) error

	// GetSpecificKeysValue get specific key value.
	Get(context.Context, *GetRequest) ([]*ConfigurationItem, error)

	// Set saves configuration into configuration store.
	Set(context.Context, *SetRequest) error

	// Delete deletes configuration from configuration store.
	Delete(context.Context, *DeleteRequest) error

	// Subscribe subscribe the configurations updates.
	Subscribe(*SubscribeReq, chan *SubscribeResp) error

	//StopSubscribe stop subs
	StopSubscribe()

	// GetDefaultGroup returns default group.This method will be invoked if a request doesn't specify the group field
	GetDefaultGroup() string

	// GetDefaultLabel returns default label
	GetDefaultLabel() string
}

Store is an interface to perform operations on config store

type StoreConfig

type StoreConfig struct {
	Type      string            `json:"type"`
	StoreName string            `json:"store_name"`
	AppId     string            `json:"app_id"`
	Address   []string          `json:"address"`
	TimeOut   string            `json:"timeout"`
	Metadata  map[string]string `json:"metadata"`
}

StoreConfig wraps configuration for a store implementation

type StoreFactory

type StoreFactory struct {
	CompType      string
	FactoryMethod func() Store
}

func NewStoreFactory

func NewStoreFactory(compType string, f func() Store) *StoreFactory

type StoreRegistry

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

func (*StoreRegistry) Create

func (r *StoreRegistry) Create(compType string) (Store, error)

func (*StoreRegistry) Register

func (r *StoreRegistry) Register(fs ...*StoreFactory)

type SubscribeReq

type SubscribeReq struct {
	AppId    string
	Group    string
	Label    string
	Keys     []string
	Metadata map[string]string
}

SubscribeReq is the object describing a subscription request

type SubscribeResp

type SubscribeResp struct {
	StoreName string
	AppId     string
	Items     []*ConfigurationItem
}

SubscribeResp is the object describing a response for subscription

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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