server

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDir     = "/var/lib/river/db"
	DefaultLogFile = "/var/lib/river/db.log"
)

Variables

View Source
var (
	ErrClosed = errors.New("server is closed")
)

Functions

func LogInterceptor

func LogInterceptor(s *Server) grpc.UnaryServerInterceptor

func RequirePassInterceptor

func RequirePassInterceptor(s *Server) grpc.UnaryServerInterceptor

Types

type Logger

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

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

Debug logs at LevelDebug.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

Error logs at LevelError.

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

Info logs at LevelInfo.

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

Warn logs at LevelWarn.

type Options

type Options struct {
	Version string
	// server listen address
	Address string `toml:"address"`
	// server password
	Password string `toml:"password"`
	// tls configuration
	TlsKey string `toml:"tls_key"`
	TlsPem string `toml:"tls_perm"`

	// max bytes size of the single data file can hold
	MaxSize int64 `toml:"max_file_size"`
	// wal block cache size
	BlockCache uint32 `toml:"block_cache"`
	// call sync per write
	Fsync bool `toml:"fsync"`
	// call sync when reach the threshold
	FsyncThreshold int64 `toml:"fsync_threshold"`
	// transaction isolation level
	TxnLevel uint8 `toml:"txn_level"`
	// merge checkpoint
	Checkpoint float64 `toml:"merge_checkpoint"`

	LogFile  string `toml:"log_file"`
	LogLevel string `toml:"log_level"`
}

func ReadOption

func ReadOption(cfgpath string) (Options, error)

ReadOption Reads option from the specified path

type Server

type Server struct {
	riverpb.UnimplementedRiverServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, option Options) (*Server, error)

NewServer return a new grpc server for river db

func (*Server) Close

func (s *Server) Close() error

func (*Server) Del

func (s *Server) Del(ctx context.Context, data *riverpb.RawData) (*riverpb.InfoResult, error)

func (*Server) DelInBatch

func (s *Server) DelInBatch(ctx context.Context, opt *riverpb.BatchDelOption) (*riverpb.BatchResult, error)

func (*Server) Exp

func (s *Server) Exp(ctx context.Context, record *riverpb.ExpRecord) (*riverpb.InfoResult, error)

func (*Server) Get

func (s *Server) Get(ctx context.Context, data *riverpb.RawData) (*riverpb.DataResult, error)

func (*Server) Put

func (s *Server) Put(ctx context.Context, record *riverpb.Record) (*riverpb.InfoResult, error)

func (*Server) PutInBatch

func (s *Server) PutInBatch(ctx context.Context, opt *riverpb.BatchPutOption) (*riverpb.BatchResult, error)

func (*Server) Range

func (*Server) Run

func (s *Server) Run() error

func (*Server) Stat

func (*Server) TTL

func (s *Server) TTL(ctx context.Context, data *riverpb.RawData) (*riverpb.TTLResult, error)

Jump to

Keyboard shortcuts

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