Documentation
¶
Index ¶
- Constants
- func EtcdClient(endpoints string) (*clientv3.Client, error)
- type DevStore
- func (s *DevStore) AddLibrary(ctx context.Context, content []byte, path string) error
- func (s *DevStore) AddScript(ctx context.Context, subject, name string, script []byte) error
- func (s *DevStore) DeleteScript(ctx context.Context, subject, name string) error
- func (s *DevStore) GetScripts(ctx context.Context, subject string) (map[string][]byte, error)
- func (s *DevStore) ListSubjects(ctx context.Context) ([]string, error)
- func (s *DevStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)
- func (s *DevStore) ReleaseLock(ctx context.Context, path string) error
- func (s *DevStore) RemoveLibrary(ctx context.Context, path string) error
- func (s *DevStore) TakeLock(ctx context.Context, path string) (bool, error)
- func (s *DevStore) WatchScripts(ctx context.Context, subject string, ...)
- type EtcdScriptStore
- func (e *EtcdScriptStore) AddLibrary(ctx context.Context, content []byte, path string) error
- func (e *EtcdScriptStore) AddScript(ctx context.Context, subject, name string, script []byte) error
- func (e *EtcdScriptStore) DeleteScript(ctx context.Context, subject, name string) error
- func (e *EtcdScriptStore) GetScripts(ctx context.Context, subject string) (map[string][]byte, error)
- func (e *EtcdScriptStore) ListSubjects(ctx context.Context) ([]string, error)
- func (e *EtcdScriptStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)
- func (e *EtcdScriptStore) ReleaseLock(ctx context.Context, path string) error
- func (e *EtcdScriptStore) RemoveLibrary(ctx context.Context, path string) error
- func (e *EtcdScriptStore) TakeLock(ctx context.Context, path string) (bool, error)
- func (e *EtcdScriptStore) WatchScripts(ctx context.Context, subject string, ...)
- type FileScriptStore
- func (f *FileScriptStore) AddLibrary(ctx context.Context, content []byte, path string) error
- func (f *FileScriptStore) AddScript(ctx context.Context, subject, name string, script []byte) error
- func (f *FileScriptStore) DeleteScript(ctx context.Context, subject, name string) error
- func (f *FileScriptStore) GetScripts(ctx context.Context, subject string) (map[string][]byte, error)
- func (f *FileScriptStore) ListSubjects(ctx context.Context) ([]string, error)
- func (f *FileScriptStore) LoadLibrairies(ctx context.Context, libraryPaths []string) ([][]byte, error)
- func (f *FileScriptStore) ReleaseLock(ctx context.Context, path string) error
- func (f *FileScriptStore) RemoveLibrary(ctx context.Context, path string) error
- func (f *FileScriptStore) TakeLock(ctx context.Context, path string) (bool, error)
- func (f *FileScriptStore) WatchScripts(ctx context.Context, subject string, ...)
- type ScriptStore
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" )
View Source
const ( BACKEND_ETCD_NAME = "etcd" BACKEND_SQLITE_NAME = "sqlite" BACKEND_FILE_NAME = "file" )
Available backend options
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DevStore ¶
type DevStore struct {
// contains filtered or unexported fields
}
func (*DevStore) AddLibrary ¶ added in v0.1.5
func (*DevStore) DeleteScript ¶
func (*DevStore) GetScripts ¶
func (*DevStore) ListSubjects ¶
func (*DevStore) LoadLibrairies ¶ added in v0.1.5
func (*DevStore) ReleaseLock ¶
func (*DevStore) RemoveLibrary ¶ added in v0.1.5
type EtcdScriptStore ¶
type EtcdScriptStore struct {
// contains filtered or unexported fields
}
EtcdScriptStore stores Lua scripts in etcd, supporting multiple scripts per subject
func NewEtcdScriptStore ¶
func NewEtcdScriptStore(endpoints string) (*EtcdScriptStore, error)
NewEtcdScriptStore creates a new instance of EtcdScriptStore
func (*EtcdScriptStore) AddLibrary ¶ added in v0.1.5
func (*EtcdScriptStore) AddScript ¶
AddScript adds a new Lua script under the given subject with a unique ID
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][]byte, 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 (*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) 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 NewFileScriptStore ¶ added in v0.3.0
func NewFileScriptStore(scriptPath string, libraryPath string) (*FileScriptStore, error)
func (*FileScriptStore) AddLibrary ¶ added in v0.3.0
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 (*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 (*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) 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, script []byte) error DeleteScript(ctx context.Context, subject, name string) error GetScripts(ctx context.Context, subject string) (map[string][]byte, 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 }
func NewDevStore ¶
func NewDevStore(libraryPath string) (ScriptStore, error)
func StoreByName ¶
func StoreByName(name, etcdEndpoints, scriptDir, libraryDir string) (ScriptStore, error)
Click to show internal directories.
Click to hide internal directories.