context

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace default namespce
	DefaultNamespace = "default"
)

Variables

View Source
var (
	ReleaseVersion = "None"
	BuildTS        = "None"
	GitHash        = "None"
	GitBranch      = "None"
	GitLog         = "None"
	GolangVersion  = "None"
	ConfigFile     = "None"
)

Version information.

Functions

func WithCancel

func WithCancel(parent *Context) (*Context, CancelFunc)

WithCancel returns a copy of parent with a new Done channel

func WithDeadline

func WithDeadline(parent *Context, d time.Time) (*Context, CancelFunc)

WithDeadline returns a copy of the parent context with the deadline adjusted to be no later than d

func WithTimeout

func WithTimeout(parent *Context, timeout time.Duration) (*Context, CancelFunc)

WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).

Types

type CancelFunc

type CancelFunc context.CancelFunc

CancelFunc tells an operation to abandon its work

type ClientContext

type ClientContext struct {
	DB            *db.DB
	Authenticated bool   // Client has be authenticated
	Namespace     string // Namespace of database
	RemoteAddr    string // Client remote address
	ID            int64  // Client uniq ID
	Name          string // Name is set by client setname
	Created       time.Time
	Updated       time.Time
	LastCmd       string
	SkipN         int // Skip N following commands, (-1 for skipping all commands)
	Close         func() error

	// When client is in multi...exec block, the Txn is assigned and Multi is set to be true
	// Before exec, all command called will be queued in Commands
	Txn      *db.Transaction // Txn is set when client is in transaction which is triggered by watch command
	Multi    bool
	Commands []*Command

	Done chan struct{}
}

ClientContext is the runtime context of a client

func NewClientContext

func NewClientContext(id int64, conn net.Conn) *ClientContext

NewClientContext new client context object ,id must be uniq

type Command

type Command struct {
	Name string
	Args []string
}

Command releated context

type Context

type Context struct {
	context.Context
	Client *ClientContext
	Server *ServerContext
}

Context combines the client and server context

func New

func New(c *ClientContext, s *ServerContext) *Context

New a context

func WithValue

func WithValue(parent *Context, key, val interface{}) *Context

WithValue returns a copy of parent in which the value associated with key is val.

type ServerContext

type ServerContext struct {
	RequirePass      string
	Store            *db.RedisStore
	Monitors         sync.Map
	Clients          sync.Map
	Pause            time.Duration // elapse to pause all clients
	StartAt          time.Time
	ListZipThreshold int
}

ServerContext is the runtime context of the server

Jump to

Keyboard shortcuts

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