freezer

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package freezer implements a persistence layer for Grumble.

Index

Constants

View Source
const (
	ServerType typeKind = iota
	ConfigKeyValuePairType
	BanListType
	UserType
	UserRemoveType
	ChannelType
	ChannelRemoveType
)

Variables

View Source
var (
	ErrTxGroupFull        = errors.New("transction group is full")
	ErrTxGroupValueTooBig = errors.New("value too big to put inside the txgroup")
)

Writer errors

View Source
var (
	ErrUnexpectedEndOfRecord   = errors.New("unexpected end of record")
	ErrCRC32Mismatch           = errors.New("CRC32 mismatch")
	ErrRemainingBytesForRecord = errors.New("remaining bytes in record")
	ErrRecordTooBig            = errors.New("the record in the file is too big")
)

Walker errors

Functions

This section is empty.

Types

type ACL

type ACL struct {
	UserId           *uint32 `protobuf:"varint,1,opt,name=user_id" json:"user_id,omitempty"`
	Group            *string `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"`
	ApplyHere        *bool   `protobuf:"varint,3,opt,name=apply_here" json:"apply_here,omitempty"`
	ApplySubs        *bool   `protobuf:"varint,4,opt,name=apply_subs" json:"apply_subs,omitempty"`
	Allow            *uint32 `protobuf:"varint,5,opt,name=allow" json:"allow,omitempty"`
	Deny             *uint32 `protobuf:"varint,6,opt,name=deny" json:"deny,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*ACL) GetAllow

func (this *ACL) GetAllow() uint32

func (*ACL) GetApplyHere

func (this *ACL) GetApplyHere() bool

func (*ACL) GetApplySubs

func (this *ACL) GetApplySubs() bool

func (*ACL) GetDeny

func (this *ACL) GetDeny() uint32

func (*ACL) GetGroup

func (this *ACL) GetGroup() string

func (*ACL) GetUserId

func (this *ACL) GetUserId() uint32

func (*ACL) ProtoMessage

func (*ACL) ProtoMessage()

func (*ACL) Reset

func (this *ACL) Reset()

func (*ACL) String

func (this *ACL) String() string

type Ban

type Ban struct {
	Ip               []byte  `protobuf:"bytes,1,opt,name=ip" json:"ip,omitempty"`
	Mask             *uint32 `protobuf:"varint,2,opt,name=mask" json:"mask,omitempty"`
	Username         *string `protobuf:"bytes,3,opt,name=username" json:"username,omitempty"`
	CertHash         *string `protobuf:"bytes,4,opt,name=cert_hash" json:"cert_hash,omitempty"`
	Reason           *string `protobuf:"bytes,5,opt,name=reason" json:"reason,omitempty"`
	Start            *int64  `protobuf:"varint,6,opt,name=start" json:"start,omitempty"`
	Duration         *uint32 `protobuf:"varint,7,opt,name=duration" json:"duration,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*Ban) GetCertHash

func (this *Ban) GetCertHash() string

func (*Ban) GetDuration

func (this *Ban) GetDuration() uint32

func (*Ban) GetIp

func (this *Ban) GetIp() []byte

func (*Ban) GetMask

func (this *Ban) GetMask() uint32

func (*Ban) GetReason

func (this *Ban) GetReason() string

func (*Ban) GetStart

func (this *Ban) GetStart() int64

func (*Ban) GetUsername

func (this *Ban) GetUsername() string

func (*Ban) ProtoMessage

func (*Ban) ProtoMessage()

func (*Ban) Reset

func (this *Ban) Reset()

func (*Ban) String

func (this *Ban) String() string

type BanList

type BanList struct {
	Bans             []*Ban `protobuf:"bytes,1,rep,name=bans" json:"bans,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

func (*BanList) ProtoMessage

func (*BanList) ProtoMessage()

func (*BanList) Reset

func (this *BanList) Reset()

func (*BanList) String

func (this *BanList) String() string

type Channel

type Channel struct {
	Id               *uint32  `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	Name             *string  `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
	ParentId         *uint32  `protobuf:"varint,3,opt,name=parent_id" json:"parent_id,omitempty"`
	Position         *int64   `protobuf:"varint,4,opt,name=position" json:"position,omitempty"`
	InheritAcl       *bool    `protobuf:"varint,5,opt,name=inherit_acl" json:"inherit_acl,omitempty"`
	Links            []uint32 `protobuf:"varint,6,rep,name=links" json:"links,omitempty"`
	Acl              []*ACL   `protobuf:"bytes,7,rep,name=acl" json:"acl,omitempty"`
	Groups           []*Group `protobuf:"bytes,8,rep,name=groups" json:"groups,omitempty"`
	DescriptionBlob  *string  `protobuf:"bytes,9,opt,name=description_blob" json:"description_blob,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*Channel) GetDescriptionBlob

func (this *Channel) GetDescriptionBlob() string

func (*Channel) GetId

func (this *Channel) GetId() uint32

func (*Channel) GetInheritAcl

func (this *Channel) GetInheritAcl() bool

func (*Channel) GetName

func (this *Channel) GetName() string

func (*Channel) GetParentId

func (this *Channel) GetParentId() uint32

func (*Channel) GetPosition

func (this *Channel) GetPosition() int64

func (*Channel) ProtoMessage

func (*Channel) ProtoMessage()

func (*Channel) Reset

func (this *Channel) Reset()

func (*Channel) String

func (this *Channel) String() string

type ChannelRemove

type ChannelRemove struct {
	Id               *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*ChannelRemove) GetId

func (this *ChannelRemove) GetId() uint32

func (*ChannelRemove) ProtoMessage

func (*ChannelRemove) ProtoMessage()

func (*ChannelRemove) Reset

func (this *ChannelRemove) Reset()

func (*ChannelRemove) String

func (this *ChannelRemove) String() string

type ConfigKeyValuePair

type ConfigKeyValuePair struct {
	Key              *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"`
	Value            *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*ConfigKeyValuePair) GetKey

func (this *ConfigKeyValuePair) GetKey() string

func (*ConfigKeyValuePair) GetValue

func (this *ConfigKeyValuePair) GetValue() string

func (*ConfigKeyValuePair) ProtoMessage

func (*ConfigKeyValuePair) ProtoMessage()

func (*ConfigKeyValuePair) Reset

func (this *ConfigKeyValuePair) Reset()

func (*ConfigKeyValuePair) String

func (this *ConfigKeyValuePair) String() string

type Group

type Group struct {
	Name             *string  `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Inherit          *bool    `protobuf:"varint,2,opt,name=inherit" json:"inherit,omitempty"`
	Inheritable      *bool    `protobuf:"varint,3,opt,name=inheritable" json:"inheritable,omitempty"`
	Add              []uint32 `protobuf:"varint,4,rep,name=add" json:"add,omitempty"`
	Remove           []uint32 `protobuf:"varint,5,rep,name=remove" json:"remove,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*Group) GetInherit

func (this *Group) GetInherit() bool

func (*Group) GetInheritable

func (this *Group) GetInheritable() bool

func (*Group) GetName

func (this *Group) GetName() string

func (*Group) ProtoMessage

func (*Group) ProtoMessage()

func (*Group) Reset

func (this *Group) Reset()

func (*Group) String

func (this *Group) String() string

type Log

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

Log implements an append-only log for flattened protobuf-encoded log entries.

These log entries are typically state-change deltas for a Grumble server's main data strutures.

The log supports atomic transactions. Transaction groups are persisted to disk with a checksum that covers the whole transaction group. In case of a failure, none of the entries of a transaction will be applied.

func NewLogFile

func NewLogFile(fn string) (*Log, error)

Create a new log file

func (*Log) BeginTx

func (log *Log) BeginTx() *LogTx

Begin a transaction

func (*Log) Close

func (log *Log) Close() error

Close a Log

func (*Log) Put

func (log *Log) Put(value interface{}) (err error)

Append a log entry

This method implicitly creates a transaction group for this single Put operation. It is merely a convenience wrapper.

type LogTx

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

Type LogTx represents a transaction in the log. Transactions can be used to group several changes into an atomic entity in the log file.

func (*LogTx) Commit

func (tx *LogTx) Commit() (err error)

Commit all changes of the transaction to the log as a single atomic entry.

func (*LogTx) Put

func (tx *LogTx) Put(value interface{}) (err error)

Append a log entry to the transaction. The transaction's log entries will not be persisted to the log until the Commit has been called on the transaction.

type Server

type Server struct {
	Config           []*ConfigKeyValuePair `protobuf:"bytes,2,rep,name=config" json:"config,omitempty"`
	BanList          *BanList              `protobuf:"bytes,3,opt,name=ban_list" json:"ban_list,omitempty"`
	Channels         []*Channel            `protobuf:"bytes,4,rep,name=channels" json:"channels,omitempty"`
	Users            []*User               `protobuf:"bytes,5,rep,name=users" json:"users,omitempty"`
	XXX_unrecognized []byte                `json:"-"`
}

func (*Server) GetBanList

func (this *Server) GetBanList() *BanList

func (*Server) ProtoMessage

func (*Server) ProtoMessage()

func (*Server) Reset

func (this *Server) Reset()

func (*Server) String

func (this *Server) String() string

type User

type User struct {
	Id               *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	Name             *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
	Password         *string `protobuf:"bytes,3,opt,name=password" json:"password,omitempty"`
	CertHash         *string `protobuf:"bytes,4,opt,name=cert_hash" json:"cert_hash,omitempty"`
	Email            *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
	TextureBlob      *string `protobuf:"bytes,6,opt,name=texture_blob" json:"texture_blob,omitempty"`
	CommentBlob      *string `protobuf:"bytes,7,opt,name=comment_blob" json:"comment_blob,omitempty"`
	LastChannelId    *uint32 `protobuf:"varint,8,opt,name=last_channel_id" json:"last_channel_id,omitempty"`
	LastActive       *uint64 `protobuf:"varint,9,opt,name=last_active" json:"last_active,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*User) GetCertHash

func (this *User) GetCertHash() string

func (*User) GetCommentBlob

func (this *User) GetCommentBlob() string

func (*User) GetEmail

func (this *User) GetEmail() string

func (*User) GetId

func (this *User) GetId() uint32

func (*User) GetLastActive

func (this *User) GetLastActive() uint64

func (*User) GetLastChannelId

func (this *User) GetLastChannelId() uint32

func (*User) GetName

func (this *User) GetName() string

func (*User) GetPassword

func (this *User) GetPassword() string

func (*User) GetTextureBlob

func (this *User) GetTextureBlob() string

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) Reset

func (this *User) Reset()

func (*User) String

func (this *User) String() string

type UserRemove

type UserRemove struct {
	Id               *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*UserRemove) GetId

func (this *UserRemove) GetId() uint32

func (*UserRemove) ProtoMessage

func (*UserRemove) ProtoMessage()

func (*UserRemove) Reset

func (this *UserRemove) Reset()

func (*UserRemove) String

func (this *UserRemove) String() string

type Walker

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

Type Walker implements a method for iterating the transaction groups of an immutable Log.

func NewReaderWalker

func NewReaderWalker(r io.Reader) (walker *Walker, err error)

Create a new Walker that iterates over the log entries of a given Reader.

func (*Walker) Next

func (walker *Walker) Next() (entries []interface{}, err error)

Next returns the next transaction group in the log as a slice of pointers to the protobuf-serialized log entries.

This method will only attempt to serialize types with type identifiers that this package knows of. In case an unknown type identifier is found in a transaction group, it is silently ignored (it's skipped).

On error, Next returns a nil slice and a non-nil err. When the end of the file is reached, Next returns nil, os.EOF.

Jump to

Keyboard shortcuts

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