object

package
v0.0.0-...-b08fcc5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTablePrefix       = "objects_"
	DefaultTableHashSize     = 16
	DefaultCompressThreshold = 4096
)

Default values

View Source
const (
	DefaultNamespace = "default"
)

Defaults

Variables

This section is empty.

Functions

This section is empty.

Types

type Object

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

Object : ...

func NewObject

func NewObject(id int64, namespace string) *Object

NewObject create new object

func (*Object) Bytes

func (o *Object) Bytes() []byte

Bytes get byte array

func (*Object) Get

func (o *Object) Get(path string) interface{}

Get value from object with given path

func (*Object) Raw

func (o *Object) Raw(r []byte)

Raw set raw data

func (*Object) Set

func (o *Object) Set(path string, value interface{})

Set value to given path

func (*Object) Unmarshal

func (o *Object) Unmarshal(i interface{}) error

Unmarshal : Unmarshal raw to struct

type Option

type Option func(o *Options)

Option : ...

func SetCompress

func SetCompress(c bool) Option

SetCompress set compress switch

func SetCompressThreshold

func SetCompressThreshold(size int) Option

SetCompressThreshold set size threshold of compress

func SetGORMClient

func SetGORMClient(db *gorm.DB) Option

SetGORMClient set gorm db connector

func SetGORMTableHashSize

func SetGORMTableHashSize(size int64) Option

SetGORMTableHashSize set table hash size of gorm

func SetGORMTablePrefix

func SetGORMTablePrefix(prefix string) Option

SetGORMTablePrefix set table prefix of gorm

func SetMongoDBClient

func SetMongoDBClient(client *mongo.Client) Option

SetMongoDBClient set mongodb connector

func SetMongoDBTablePrefix

func SetMongoDBTablePrefix(prefix string) Option

SetMongoDBTablePrefix set table prefix of mongodb

func SetRedisClient

func SetRedisClient(rdb *redis.Client) Option

SetRedisClient set redis client

type Options

type Options struct {
	Backend StorageBackend

	// Serialization
	Serializer Serializer
	// contains filtered or unexported fields
}

Options : storage options

type Serializer

type Serializer int8

Serializer : Serialize type hinting

const (
	JSONSerialization    Serializer = 0
	MsgPackSerialization Serializer = 19
)

Serializations

type StorageBackend

type StorageBackend int8

StorageBackend : Enum of backend

const (
	GORMBackend    StorageBackend = 0
	MongoDBBackend StorageBackend = 1
)

Backends

type Store

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

Store : Object storage

func NewStore

func NewStore(opts ...Option) *Store

NewStore create new object storage

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, o *Object) error

Delete object

func (*Store) Load

func (s *Store) Load(ctx context.Context, id int64, namespace string) (*Object, error)

Load object

func (*Store) Save

func (s *Store) Save(ctx context.Context, o *Object) error

Save object

Jump to

Keyboard shortcuts

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