keyvalues

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 3 Imported by: 5

README

keyvalues

一套抽象的 key-value 存储 api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMainModule

func NewMainModule() *application.ModuleBuilder

NewMainModule ...

func NewTestModule

func NewTestModule() *application.ModuleBuilder

NewTestModule ...

Types

type BinaryEntry

type BinaryEntry interface {
	Entry

	Put(value []byte, opt *Options) error

	Get() ([]byte, error)
}

BinaryEntry 是 二进制 形式的 Entry

type Class

type Class interface {
	Name() ClassName

	Alias() ClassAlias

	Namespace() Namespace

	GetTextEntry(id string) TextEntry

	GetBinaryEntry(id string) BinaryEntry

	GetJSONEntry(id string) JSONEntry
}

Class 代表一个类型

type ClassAlias

type ClassAlias string

ClassAlias 表示类型的别名

func (ClassAlias) String

func (cn ClassAlias) String() string

type ClassGetter

type ClassGetter interface {
	GetClass(name ClassName) (Class, error)
}

ClassGetter ...

type ClassInfo

type ClassInfo struct {
	ID string // 在 properties 中的 ID

	Namespace  NS         // refer to NS.name
	Store      string     // refer to Store.name
	SimpleName SimpleName // simple name of this class
	MaxAge     time.Duration
	Enabled    bool

	Class  Class
	Loader ClassLoader
}

ClassInfo ...

type ClassLoader

type ClassLoader interface {
	LoadClass(name ClassName) (Class, error)
}

ClassLoader ...

type ClassName

type ClassName string

ClassName 表示类型的全名 (namespace + simpleName)

func (ClassName) String

func (cn ClassName) String() string

type Configuration

type Configuration struct {
	Name          string // name of this config
	Driver        string
	Host          string
	Port          int
	Username      string
	Password      string
	DefaultMaxAge time.Duration
	Enabled       bool
}

Configuration 表示 store 的配置

type Driver

type Driver interface {
	Open(cfg *Configuration) (Store, error)
}

Driver 代表 store 的驱动

type DriverGetter

type DriverGetter interface {
	GetDriver(name string) (Driver, error)
}

DriverGetter ...

type DriverInfo

type DriverInfo struct {
	Name   string
	Driver Driver
}

DriverInfo ...

type Entry

type Entry interface {
	Class() Class

	Key() string
}

Entry 代表 store 中的一个条目

type JSONEntry

type JSONEntry interface {
	Entry

	Put(value any, opt *Options) error

	Get(value any) error
}

JSONEntry 是 JSON 形式的 Entry

type NS

type NS string

NS 表示命名空间的字符串形式

func (NS) GetClassName

func (ns NS) GetClassName(alias ClassAlias) ClassName

GetClassName 取类型的全名

func (NS) String

func (ns NS) String() string

type Namespace

type Namespace interface {
	Name() NS

	GetClass(alias ClassAlias) (Class, error)
}

Namespace 代表命名空间

type NamespaceGetter

type NamespaceGetter interface {
	GetNamespace(ns NS) (Namespace, error)
}

NamespaceGetter ...

type NamespaceInfo

type NamespaceInfo struct {
	Name      NS
	Namespace Namespace
}

NamespaceInfo ...

type NamespaceLoader

type NamespaceLoader interface {
	LoadNamespace(ns NS) (Namespace, error)
}

NamespaceLoader ...

type Options

type Options struct {
	MaxAge time.Duration
}

Options 表示 store 的操作选项

type Registration

type Registration struct {
	Enabled  bool
	Priority int

	Driver *DriverInfo
}

Registration 注册信息

type Registry

type Registry interface {
	ListRegistrations() []*Registration
}

Registry ...

type Service

type Service interface {
	GetClassNS(ns NS, alias ClassAlias) (Class, error)

	ClassGetter
	DriverGetter
	NamespaceGetter
	StoreGetter
}

Service 提供面向客户端的服务

type SimpleName

type SimpleName = ClassAlias

SimpleName 表示类型的短名称

type Store

type Store interface {
	Put(key string, value []byte, opt *Options) error
	Get(key string) ([]byte, error)
	Contains(key string) (bool, error)
}

Store 代表一个存储库

type StoreGetter

type StoreGetter interface {
	GetStore(name string) (Store, error)
}

StoreGetter ...

type StoreInfo

type StoreInfo struct {
	Enabled bool
	Name    string

	Host     string
	Port     int
	Username string
	Password string
	Driver   string
	MaxAge   time.Duration

	Store Store
}

StoreInfo ...

type StoreLoader

type StoreLoader interface {
	LoadStore(name string) (Store, error)
}

StoreLoader ...

type TextEntry

type TextEntry interface {
	Entry

	Put(value string, opt *Options) error

	Get() (string, error)
}

TextEntry 是 文本 形式的 Entry

type Want

type Want struct {
	Namespace string
	Class     SimpleName
	ID        string
}

Want 表示一个查询条件

Jump to

Keyboard shortcuts

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