Documentation ¶
Index ¶
- Constants
- func CreateLogFolder(logpath string) error
- func CreateLogger(cfg *Config) *logger.Logger
- func CreateSessionID() string
- func IsProduction(env string) bool
- func StartClientSession(conn net.Conn) (string, error)
- func Version() string
- type Cache
- func (c Cache) Close()
- func (c Cache) CreateOptions() *bolt.Options
- func (c Cache) Delete(key []byte) error
- func (c Cache) Get(key []byte) ([]byte, error)
- func (c Cache) Has(key []byte) (bool, error)
- func (c Cache) Keys() ([]string, error)
- func (c Cache) Open() error
- func (c Cache) Put(key, value []byte, ttl TTLSeconds) error
- func (c *Cache) TTL(key []byte) TTLSeconds
- type CacheService
- type Command
- type CommandOp
- type Commander
- type Config
- type IDType
- type Request
- type RequestBuilder
- func (rb *RequestBuilder) CreateDeleteRequest(key, metadata []byte) *Request
- func (rb *RequestBuilder) CreateGetRequest(key, metadata []byte) *Request
- func (rb *RequestBuilder) CreateHasRequest(key, metadata []byte) *Request
- func (rb *RequestBuilder) CreateKeysRequest(key, metadata []byte) *Request
- func (rb *RequestBuilder) CreatePingRequest() *Request
- func (rb *RequestBuilder) CreatePutRequest(key, value, metadata []byte) *Request
- func (rb RequestBuilder) NewRequest(op CommandOp) Request
- type Response
- type SessionType
- type TTLSeconds
Constants ¶
const ( ResponseOk = "ok" ResponseFail = "fail" ResponseTrue = "true" ResponseFalse = "false" ResponsePong = "pong" )
public constants
const ( NOOP = CommandOp(0) PUT = CommandOp(1) GET = CommandOp(2) HAS = CommandOp(3) DELETE = CommandOp(4) BATCH = CommandOp(9) EXPIRE = CommandOp(10) TTL = CommandOp(11) SUBSCRIBE = CommandOp(20) UNSUBSCRIBE = CommandOp(21) PUBLISH = CommandOp(22) KEYS = CommandOp(30) BACKUP = CommandOp(110) CLEAR = CommandOp(119) STATUS = CommandOp(127) PING = CommandOp(128) SHUTDOWN = CommandOp(255) )
manually assign the op codes...
Variables ¶
This section is empty.
Functions ¶
func CreateLogFolder ¶
CreateLogFolder - create the log folder if it doesn't already exist
func CreateLogger ¶
CreateLogger create a new logger based on config
func IsProduction ¶
IsProduction return true if the current env is production
func StartClientSession ¶
StartClientSession create a client session id and send to the new client (move to sock utils?)
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache the cache object
func (Cache) CreateOptions ¶
CreateOptions create the cache options
type CacheService ¶
type CacheService struct { ClientCount int CreateDate time.Time Port int DbPath string Timeout time.Duration // contains filtered or unexported fields }
CacheService - the main struct with client count, port, etc
func NewCacheService ¶
func NewCacheService(cfg *Config) CacheService
NewCacheService - create a cache service
func (*CacheService) CreateListener ¶
func (s *CacheService) CreateListener() (*net.TCPListener, error)
CreateListener create the listener for the specified address/port
func (*CacheService) InitializeCache ¶
func (s *CacheService) InitializeCache(cfg *Config)
InitializeCache configure the commander and cache database
func (*CacheService) ListenAndServe ¶
func (s *CacheService) ListenAndServe(ss *net.TCPListener)
ListenAndServe open the cache database and start the main socket service; block forever...
func (*CacheService) OpenClientHandler ¶
func (s *CacheService) OpenClientHandler(conn net.Conn)
OpenClientHandler handle client requests as long as they stay connected
type Command ¶
Command command object to support executions
func CreateCommand ¶
CreateCommand a public helper method to create a full comman structure
type Commander ¶
type Commander struct { }
Commander the commander struct
func NewCommander ¶
NewCommander create a new command object
type Config ¶
type Config struct { Home string // defaults to user's home Env string // defaults to production Logpath string Logname string Dbpath string Baseport int Timeout int64 }
Config the config structure
func NewConfigForEnvironment ¶
NewConfigForEnvironment configure for a specific environment
type Request ¶
type Request struct { ID IDType Session SessionType Op CommandOp MetaSize uint16 KeySize uint16 DataSize uint32 Metadata []byte Key []byte Value []byte }
Request request object as created by the client
func RequestFromBytes ¶
RequestFromBytes decode the little endian bytes and parse into request object
func (*Request) CreateResponse ¶
CreateResponse create a response object from the reqest, response value and new meta data
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
RequestBuilder holds the session
func NewRequestBuilder ¶
func NewRequestBuilder(sess SessionType) *RequestBuilder
NewRequestBuilder return a new request builder object
func (*RequestBuilder) CreateDeleteRequest ¶
func (rb *RequestBuilder) CreateDeleteRequest(key, metadata []byte) *Request
CreateDeleteRequest create a delete request op
func (*RequestBuilder) CreateGetRequest ¶
func (rb *RequestBuilder) CreateGetRequest(key, metadata []byte) *Request
CreateGetRequest create a get request
func (*RequestBuilder) CreateHasRequest ¶
func (rb *RequestBuilder) CreateHasRequest(key, metadata []byte) *Request
CreateHasRequest return the has request op
func (*RequestBuilder) CreateKeysRequest ¶
func (rb *RequestBuilder) CreateKeysRequest(key, metadata []byte) *Request
CreateKeysRequest create a keys request
func (*RequestBuilder) CreatePingRequest ¶
func (rb *RequestBuilder) CreatePingRequest() *Request
CreatePingRequest create a simple ping request
func (*RequestBuilder) CreatePutRequest ¶
func (rb *RequestBuilder) CreatePutRequest(key, value, metadata []byte) *Request
CreatePutRequest create a put command with the current session
func (RequestBuilder) NewRequest ¶
func (rb RequestBuilder) NewRequest(op CommandOp) Request
NewRequest create a new request object