Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ETCD_TIMEOUT            = 3 * time.Second
	ETCD_SESSION_TTL        = 3 // In seconds
	ETCD_SCRIPT_KEY_PREFIX  = "msgscript/scripts"
	ETCD_LIBRARY_KEY_PREFIX = "msgscript/libs"
	ETCD_BACKEND_NAME       = "etcd"
)
View Source
const (
	BACKEND_ETCD_NAME   = "etcd"
	BACKEND_SQLITE_NAME = "sqlite"
	BACKEND_FILE_NAME   = "file"
)

Available backend options

View Source
const DEV_BACKEND_NAME = "dev"
View Source
const FILE_BACKEND_NAME = "file"

Variables

This section is empty.

Functions

func EtcdClient added in v0.1.7

func EtcdClient(endpoints string) (*clientv3.Client, error)

Types

type DevStore

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

func (*DevStore) AddLibrary added in v0.1.5

func (s *DevStore) AddLibrary(ctx context.Context, content []byte, path string) error

func (*DevStore) AddScript

func (s *DevStore) AddScript(ctx context.Context, subject, name string, script *script.Script) error

func (*DevStore) BackendName added in v1.0.0

func (s *DevStore) BackendName() string

func (*DevStore) DeleteScript

func (s *DevStore) DeleteScript(ctx context.Context, subject, name string) error

func (*DevStore) GetScripts

func (s *DevStore) GetScripts(ctx context.Context, subject string) (map[string]*script.Script, error)

func (*DevStore) ListSubjects

func (s *DevStore) ListSubjects(ctx context.Context) ([]string, error)

func (*DevStore) LoadLibrairies added in v0.1.5

func (s *DevStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)

func (*DevStore) ReleaseLock

func (s *DevStore) ReleaseLock(ctx context.Context, path string) error

func (*DevStore) RemoveLibrary added in v0.1.5

func (s *DevStore) RemoveLibrary(ctx context.Context, path string) error

func (*DevStore) TakeLock

func (s *DevStore) TakeLock(ctx context.Context, path string) (bool, error)

func (*DevStore) WatchScripts

func (s *DevStore) WatchScripts(ctx context.Context, subject string, onChange func(subject, name string, script []byte, delete bool))

type EtcdScriptStore

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

EtcdScriptStore stores Lua scripts in etcd, supporting multiple scripts per subject

func (*EtcdScriptStore) AddLibrary added in v0.1.5

func (e *EtcdScriptStore) AddLibrary(ctx context.Context, content []byte, path string) error

func (*EtcdScriptStore) AddScript

func (e *EtcdScriptStore) AddScript(ctx context.Context, subject, name string, scr *script.Script) error

AddScript adds a new Lua script under the given subject with a unique ID

func (*EtcdScriptStore) BackendName added in v1.0.0

func (e *EtcdScriptStore) BackendName() string

func (*EtcdScriptStore) DeleteScript

func (e *EtcdScriptStore) DeleteScript(ctx context.Context, subject, name string) error

DeleteScript deletes a specific Lua script for a subject by its name

func (*EtcdScriptStore) GetScripts

func (e *EtcdScriptStore) GetScripts(ctx context.Context, subject string) (map[string]*script.Script, error)

GetScripts retrieves all scripts associated with a subject

func (*EtcdScriptStore) ListSubjects

func (e *EtcdScriptStore) ListSubjects(ctx context.Context) ([]string, error)

func (*EtcdScriptStore) LoadLibrairies added in v0.1.5

func (e *EtcdScriptStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)

func (*EtcdScriptStore) ReleaseLock

func (e *EtcdScriptStore) ReleaseLock(ctx context.Context, path string) error

func (*EtcdScriptStore) RemoveLibrary added in v0.1.5

func (e *EtcdScriptStore) RemoveLibrary(ctx context.Context, path string) error

func (*EtcdScriptStore) TakeLock

func (e *EtcdScriptStore) TakeLock(ctx context.Context, path string) (bool, error)

func (*EtcdScriptStore) WatchScripts

func (e *EtcdScriptStore) WatchScripts(ctx context.Context, subject string, onChange func(subject, name string, script []byte, deleted bool))

WatchScripts watches for changes to scripts for a specific subject

type FileScriptStore added in v0.3.0

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

func (*FileScriptStore) AddLibrary added in v0.3.0

func (f *FileScriptStore) AddLibrary(ctx context.Context, content []byte, path string) error

func (*FileScriptStore) AddScript added in v0.3.0

func (f *FileScriptStore) AddScript(ctx context.Context, subject, name string, scr *script.Script) error

func (*FileScriptStore) BackendName added in v1.0.0

func (f *FileScriptStore) BackendName() string

func (*FileScriptStore) DeleteScript added in v0.3.0

func (f *FileScriptStore) DeleteScript(ctx context.Context, subject, name string) error

func (*FileScriptStore) GetScripts added in v0.3.0

func (f *FileScriptStore) GetScripts(ctx context.Context, subject string) (map[string]*script.Script, error)

func (*FileScriptStore) ListSubjects added in v0.3.0

func (f *FileScriptStore) ListSubjects(ctx context.Context) ([]string, error)

func (*FileScriptStore) LoadLibrairies added in v0.3.0

func (f *FileScriptStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)

func (*FileScriptStore) ReleaseLock added in v0.3.0

func (f *FileScriptStore) ReleaseLock(ctx context.Context, path string) error

func (*FileScriptStore) RemoveLibrary added in v0.3.0

func (f *FileScriptStore) RemoveLibrary(ctx context.Context, path string) error

func (*FileScriptStore) TakeLock added in v0.3.0

func (f *FileScriptStore) TakeLock(ctx context.Context, path string) (bool, error)

func (*FileScriptStore) WatchScripts added in v0.3.0

func (f *FileScriptStore) WatchScripts(ctx context.Context, subject string, onChange func(subject, path string, script []byte, deleted bool))

WatchScripts uses fsnotify to monitor the script file for changes

type ScriptStore

type ScriptStore interface {
	AddScript(ctx context.Context, subject string, name string, scr *script.Script) error
	DeleteScript(ctx context.Context, subject, name string) error
	GetScripts(ctx context.Context, subject string) (map[string]*script.Script, error)
	ReleaseLock(ctx context.Context, path string) error
	TakeLock(ctx context.Context, path string) (bool, error)
	WatchScripts(ctx context.Context, subject string, onChange func(subject, path string, script []byte, deleted bool))
	ListSubjects(ctx context.Context) ([]string, error)
	LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)
	AddLibrary(ctx context.Context, content []byte, path string) error
	RemoveLibrary(ctx context.Context, path string) error
	BackendName() string
}

func NewDevStore

func NewDevStore(libraryPath string) (ScriptStore, error)

func NewEtcdScriptStore

func NewEtcdScriptStore(endpoints string) (ScriptStore, error)

NewEtcdScriptStore creates a new instance of EtcdScriptStore

func NewFileScriptStore added in v0.3.0

func NewFileScriptStore(scriptPath string, libraryPath string) (ScriptStore, error)

func StoreByName

func StoreByName(name, etcdEndpoints, scriptDir, libraryDir string) (ScriptStore, error)

Jump to

Keyboard shortcuts

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