Documentation ¶
Index ¶
- Variables
- func InterfaceTo[T any](i interface{}) T
- func InterfaceToWithBool[T any](i interface{}, b bool) (T, bool)
- func InterfaceToWithError[T any](i interface{}, err error) (T, error)
- type Int32
- type Int64
- type KvOption
- type KvStore
- type KvStoreConfig
- type Object
- type Serializable
- type SpinLock
- type TTLSerializable
- type TtlObject
- type Uint32
- type Uint64
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Err_NotFound = errors.New("atur: not found") Err_TimeOut = errors.New("atur: timeout") )
Functions ¶
func InterfaceTo ¶
func InterfaceTo[T any](i interface{}) T
func InterfaceToWithBool ¶
func InterfaceToWithError ¶
Types ¶
type KvOption ¶
type KvOption func(*KvStoreConfig)
type KvStore ¶
type KvStore interface { // Set kv pair to KVstore // input: // ctx : context // key : []byte // value : a Serializable Object, must be a point // // return : // error SetCtx(ctx context.Context, key []byte, value Serializable) (err error) // Delete the key from KVstore // input: // ctx : context // key : []byte // // return: // error DelCtx(ctx context.Context, key []byte) (err error) // Get kv pair from KVstore // input: // ctx : context // key : []byte // value : a Serializable Object, must be an initialized point, // a null point is not availiable. // // return: // error GetCtx(ctx context.Context, key []byte, value Serializable) (err error) // Set a TTL kv pair to KVstore // input: // ctx : context // key : []byte // value : a Serializable Object, must be a TTLSerializable point // // return: // error SetTTLCtx(ctx context.Context, key []byte, value TTLSerializable) (err error) // Get TTL kv pair from KVstore // input: // ctx : context // key : []byte // value : a TTLSerializable Object, must be an initialized point, // a null point is not availiable. // // return: // error GetTTLCtx(ctx context.Context, key []byte, value TTLSerializable) (err error) // Check if the key exist or not // input: // ctx : context // key : []byte // // return: // exist bool Exist(ctx context.Context, key []byte) (exist bool) // maybe only used by leveldbKvStore GetFull() map[string]string Close() (err error) }
func NewKvStore ¶
func NewKvStore(kvConf *KvStoreConfig) (KvStore, error)
type KvStoreConfig ¶
type KvStoreConfig struct { Dir string Shards int LeveldbOptions *leveldbOpt.Options }
func DefaultKvConfig ¶
func DefaultKvConfig() *KvStoreConfig
func NewKvConfig ¶
func NewKvConfig(opts ...KvOption) (ksc *KvStoreConfig)
type Object ¶
type Object interface { GetId() []byte Serializable }
type Serializable ¶
type Serializable interface { // This function support to serialize the object to []byte // in order to write down to the disk // this fuction **MUST** be no error, this rule must be // obeyed by the implementor. Serialize() []byte // Unserialize the []byte to Object. Unserialize(s []byte) (err error) }
type TTLSerializable ¶
type TTLSerializable interface { TtlObject Serializable }
type TtlObject ¶
type TtlObject interface { // return the last time (unix ms) this Object can keep. GetTTLTime() int64 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.