conncontext

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace is default namespace of DB
	DefaultNamespace = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFlag

type ClientFlag int
const (
	ClientNone ClientFlag = 0
	// This client is a slave monitor
	ClientMonitor ClientFlag = 1 << iota
)

type ClientType

type ClientType int
const (
	ClientNormal ClientType = iota // 0
	ClientTypeMax
)

func GetClientTypeByName

func GetClientTypeByName(str string) ClientType

type CodecContext

type CodecContext struct {
	Conn          net.Conn
	ID            int64
	DB            *storage.DB
	StartTime     time.Time
	CloseChan     chan struct{}
	Authenticated bool
	Reader        *bufio.Reader
	TotalBytes    *int64
	TotalArgvLen  int64
	ArgvMem       int64
	Fd            int // set -1 if get fd of conn failed
	Name          string
	LastCmdTime   time.Time
	LastArgvLen   int64
	LastCmd       string
	RespVer       int        // only support 2 currently
	Flag          ClientFlag // only support ClientNone currently
	Type          ClientType // only support ClientNormal currently
	QueLimit      int64
	QueNum        *atomic.Int64
}

CodecContext completes interface of OBKV RPC Server

func NewCodecCtx

func NewCodecCtx(conn net.Conn, id int64, db *storage.DB, queLimit int) *CodecContext

NewCodecCtx creates a new client context

type ReadCounter

type ReadCounter struct {
	TotalBytes int64
	// contains filtered or unexported fields
}

ReadCounter record totoal bytes read from reader

func (*ReadCounter) Read

func (rc *ReadCounter) Read(p []byte) (int, error)

type ServerContext

type ServerContext struct {
	Storage   storage.Storage
	StartTime time.Time
	Password  string
	DbNum     int64

	SuperMode       SupervisedMode
	RunID           string
	Port            int
	ModisPath       string
	ConfigPath      string
	ClientNum       int
	MaxClientNum    int
	TotalClientNum  int64
	RejectClientNum int64
	Backend         string
	// [cliend id, CodecContext], record all clients
	Clients map[int64]*CodecContext
	// [cliend id, CodecContext], record clients with monitor
	Monitors map[int64]*CodecContext

	// atomic, include all clients
	TotalCmdNum     *metrics.Metrics
	TotalReadBytes  *metrics.Metrics
	TotalWriteBytes *metrics.Metrics

	ClientsPeakMemInput  int64
	ClientsPeakMemOutput int64
	// contains filtered or unexported fields
}

ServerContext connect server and clients

func NewServerContext

func NewServerContext(s storage.Storage, cfg *config.Config, cfgPath string) (*ServerContext, error)

NewServerContext creates a new client context

func (*ServerContext) GetDB

func (sc *ServerContext) GetDB(index int64) (*storage.DB, error)

GetDB prevents visit db out of range

func (*ServerContext) IsDBInit

func (sc *ServerContext) IsDBInit(index int64) bool

func (*ServerContext) StartMetricsTicker

func (sc *ServerContext) StartMetricsTicker()

type SupervisedMode

type SupervisedMode int
const (
	SupervisedNone    SupervisedMode = iota // 0
	SupervisedUnknown                       // 1
	SupervisedSystemd                       // 2
	SupervisedUpstart                       // 3
)

Jump to

Keyboard shortcuts

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