Documentation ¶
Index ¶
- Variables
- func NoopFilter(index string, data []byte) ([]byte, error)
- func NoopHook(index string) error
- func StorageGetNRangeTest(app *Server, t *testing.T, n int)
- func StorageGetNTest(app *Server, t *testing.T, n int)
- func StorageKeysRangeTest(app *Server, t *testing.T, n int)
- func StorageListTest(app *Server, t *testing.T, testData string)
- func StorageObjectTest(app *Server, t *testing.T)
- func StorageSetGetDelTest(db Database, b *testing.B)
- func StreamBroadcastFilterTest(t *testing.T, app *Server)
- func StreamBroadcastTest(t *testing.T, app *Server)
- func StreamGlobBroadcastTest(t *testing.T, app *Server, n int)
- func StreamItemGlobBroadcastTest(t *testing.T, app *Server)
- func Time() string
- func WatchStorageNoop(dataStore Database)
- type Apply
- type ApplyDelete
- type Database
- type MemoryStorage
- func (db *MemoryStorage) Active() bool
- func (db *MemoryStorage) Clear()
- func (db *MemoryStorage) Close()
- func (db *MemoryStorage) Del(path string) error
- func (db *MemoryStorage) Get(path string) ([]byte, error)
- func (db *MemoryStorage) GetN(path string, limit int) ([]objects.Object, error)
- func (db *MemoryStorage) GetNRange(path string, limit int, from, to int64) ([]objects.Object, error)
- func (db *MemoryStorage) Keys() ([]byte, error)
- func (db *MemoryStorage) KeysRange(path string, from, to int64) ([]string, error)
- func (db *MemoryStorage) Peek(key string, now int64) (int64, int64)
- func (db *MemoryStorage) Pivot(path string, data string, created int64, updated int64) (string, error)
- func (db *MemoryStorage) Set(path string, data string) (string, error)
- func (db *MemoryStorage) Start(storageOpt StorageOpt) error
- func (db *MemoryStorage) Watch() StorageChan
- type Notify
- type Server
- func (app *Server) Active() bool
- func (app *Server) AfterFilter(path string, apply Notify)
- func (app *Server) Close(sig os.Signal)
- func (app *Server) DeleteFilter(path string, apply ApplyDelete)
- func (app *Server) OpenFilter(name string)
- func (app *Server) ReadFilter(path string, apply Apply)
- func (app *Server) Start(address string)
- func (app *Server) WaitClose()
- func (app *Server) WriteFilter(path string, apply Apply)
- type Stats
- type Storage
- type StorageChan
- type StorageEvent
- type StorageOpt
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var TEST_DATA = `` /* 11110-byte string literal not displayed */
https://gist.github.com/slaise/9b9d63e0d59e8c8923bbd9d53f5beb61 https://medium.com/geekculture/my-golang-json-evaluation-20a9ca6ef79c
Functions ¶
func NoopFilter ¶
NoopFilter open noop filter
func StorageGetNRangeTest ¶
StorageGetNRangeTest testing storage GetN function
func StorageGetNTest ¶
StorageGetNTest testing storage GetN function
func StorageKeysRangeTest ¶
StorageKeysRangeTest testing storage GetN function
func StorageListTest ¶
StorageListTest testing storage function
func StorageObjectTest ¶
StorageObjectTest testing storage function
func StorageSetGetDelTest ¶
StorageSetGetDelTest testing storage function
func StreamBroadcastFilterTest ¶
StreamBroadcastFilterTest testing stream function
func StreamBroadcastTest ¶
StreamBroadcastTest testing stream function
func StreamGlobBroadcastTest ¶
StreamGlobBroadcastTest testing stream function
func StreamItemGlobBroadcastTest ¶
StreamItemGlobBroadcastTest testing stream function
func WatchStorageNoop ¶
func WatchStorageNoop(dataStore Database)
WatchStorageNoop a noop reader of the watch channel
Types ¶
type Apply ¶
Apply filter function type for functions will serve as filters key: the key to filter data: the data received or about to be sent returns data: to be stored or sent to the client error: will prevent data to pass the filter
type Database ¶
type Database interface { Active() bool Start(StorageOpt) error Close() Keys() ([]byte, error) KeysRange(path string, from, to int64) ([]string, error) Get(key string) ([]byte, error) GetN(path string, limit int) ([]objects.Object, error) GetNRange(path string, limit int, from, to int64) ([]objects.Object, error) Set(key string, data string) (string, error) Pivot(key string, data string, created, updated int64) (string, error) Del(key string) error Clear() Watch() StorageChan }
Database interface to be implemented by storages
Active: returns a boolean with the state of the storage
Start: will attempt to start a storage client
Close: closes the storage client
Keys: returns a list with existing keys in the storage
Get(key): retrieve a value or list of values, the key can include a glob pattern
GetN(path, N): retrieve N list of values matching a glob pattern
Set(key, data): store data under the provided key, key cannot not include glob pattern
Del(key): Delete a key from the storage
Clear: will clear all keys from the storage (used for testing)
Watch: returns a channel that will receive any set or del operation
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage composition of Database interface
func (*MemoryStorage) Active ¶
func (db *MemoryStorage) Active() bool
Active provides access to the status of the storage client
func (*MemoryStorage) Del ¶
func (db *MemoryStorage) Del(path string) error
Del a key/pattern value(s)
func (*MemoryStorage) Get ¶
func (db *MemoryStorage) Get(path string) ([]byte, error)
Get a key/pattern related value(s)
func (*MemoryStorage) GetNRange ¶
func (db *MemoryStorage) GetNRange(path string, limit int, from, to int64) ([]objects.Object, error)
GetNRange get last N elements of a path related value(s)
func (*MemoryStorage) Keys ¶
func (db *MemoryStorage) Keys() ([]byte, error)
Keys list all the keys in the storage
func (*MemoryStorage) KeysRange ¶
func (db *MemoryStorage) KeysRange(path string, from, to int64) ([]string, error)
KeysRange list keys in a path and time range
func (*MemoryStorage) Peek ¶
func (db *MemoryStorage) Peek(key string, now int64) (int64, int64)
Peek a value timestamps
func (*MemoryStorage) Pivot ¶
func (db *MemoryStorage) Pivot(path string, data string, created int64, updated int64) (string, error)
Pivot set entries on pivot instances (force created/updated values)
func (*MemoryStorage) Set ¶
func (db *MemoryStorage) Set(path string, data string) (string, error)
Set a value
func (*MemoryStorage) Start ¶
func (db *MemoryStorage) Start(storageOpt StorageOpt) error
Start the storage client
func (*MemoryStorage) Watch ¶
func (db *MemoryStorage) Watch() StorageChan
Watch the storage set/del events
type Server ¶
type Server struct { Router *mux.Router Stream stream.Stream Pivot string NoBroadcastKeys []string DbOpt interface{} Audit audit Workers int ForcePatch bool OnSubscribe stream.Subscribe OnUnsubscribe stream.Unsubscribe OnClose func() Deadline time.Duration AllowedOrigins []string AllowedMethods []string AllowedHeaders []string ExposedHeaders []string Storage Database Address string Silence bool Static bool Tick time.Duration Console *coat.Console Signal chan os.Signal Client *http.Client ReadTimeout time.Duration WriteTimeout time.Duration ReadHeaderTimeout time.Duration IdleTimeout time.Duration // contains filtered or unexported fields }
Server application
Router: can be predefined with routes and passed to be extended
NoBroadcastKeys: array of keys that should not broadcast on changes
DbOpt: options for storage
Audit: function to audit requests
Workers: number of workers to use as readers of the storage->broadcast channel
ForcePatch: flag to force patch operations even if the patch is bigger than the snapshot
OnSubscribe: function to monitor subscribe events
OnUnsubscribe: function to monitor unsubscribe events
OnClose: function that triggers before closing the application
Deadline: time duration of a request before timing out
AllowedOrigins: list of allowed origins for cross domain access, defaults to ["*"]
AllowedMethods: list of allowed methods for cross domain access, defaults to ["GET", "POST", "DELETE", "PUT"]
AllowedHeaders: list of allowed headers for cross domain access, defaults to ["Authorization", "Content-Type"]
ExposedHeaders: list of exposed headers for cross domain access, defaults to nil
Storage: database interdace implementation
Silence: output silence flag
Static: static routing flag
Tick: time interval between ticks on the clock subscription
Signal: os signal channel
Client: http client to make requests
Example ¶
package main import ( "github.com/benitogf/katamari" ) func main() { app := katamari.Server{} app.Start("localhost:8800") app.WaitClose() }
Output:
func (*Server) AfterFilter ¶
AfterFilter add a filter that triggers after a successful write
func (*Server) DeleteFilter ¶
func (app *Server) DeleteFilter(path string, apply ApplyDelete)
DeleteFilter add a filter that runs before sending a read result
func (*Server) OpenFilter ¶
OpenFilter open noop read and write filters
func (*Server) ReadFilter ¶
ReadFilter add a filter that runs before sending a read result
func (*Server) WaitClose ¶
func (app *Server) WaitClose()
WaitClose : Blocks waiting for SIGINT, SIGTERM, SIGKILL, SIGHUP
func (*Server) WriteFilter ¶
WriteFilter add a filter that triggers on write
type StorageEvent ¶
StorageEvent an operation event
type StorageOpt ¶
type StorageOpt struct { NoBroadcastKeys []string DbOpt interface{} }
StorageOpt options of the storage instance