db

package
v2.0.0-...-4530641 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SessionOpenStream is an argument for Do
	SessionOpenStream sessionCmd = iota
	//SessionStreamWriteMRT is an argument for Send
	SessionStreamWriteMRT
)

Variables

This section is empty.

Functions

func GetCaptures

func GetCaptures(sess *Session, req *pb.GetRequest) chan pb.GetReply

GetCaptures services a GetCapture request by returning a channel of capturedMessages. These are fetched from the db and are not parsed. They are passed as protobuf streams. It invokes a new goroutine to be able to not block on the channel send.

Types

type CommonMessage

type CommonMessage interface {
	GetMainTable() string // This table holds the names of all other tables created
	GetNodeTable() string // This holds all info on the collectors
	SetMainTable(string)
	SetNodeTable(string)
}

CommonMessage is a basic interface which allows the getting and setting of the the main and node tables that are usually involved in most db operations

type CommonReply

type CommonReply interface {
	Error() error
}

CommonReply is an interface that provides the Error interface

type Dber

type Dber interface {
	Db() *sql.DB
}

Dber is an interface that returns a reference to the underlying *sql.DB

type SerializableReply

type SerializableReply interface {
	CommonReply
	encoding.BinaryMarshaler
}

SerializableReply is a CommonReply that provides Error as well as something that can be Marshaled to Binary

type Session

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

Session represents a session to the underlying db. It holds references to the schema manager and workerpool.

func NewSession

func NewSession(parentCtx context.Context, conf config.SessionConfiger, id string, nworkers int) (*Session, error)

NewSession returns a newly allocated Session

func (*Session) Close

func (s *Session) Close() error

Close stops the schema manager and the worker pool

func (*Session) Db

func (s *Session) Db() *sql.DB

Db satisfies the Dber interface on a Session

func (*Session) Do

func (s *Session) Do(cmd sessionCmd, arg interface{}) (*SessionStream, error)

Do returns a SessionStream that will provide the output from the Do command Maybe this should return a channel that the calling function could read from to get the reply

func (*Session) GetMaxWorkers

func (s *Session) GetMaxWorkers() int

GetMaxWorkers returns the maximum amount of workers that the session supports

type SessionExecutor

type SessionExecutor interface {
	util.SQLErrorExecutor
	// contains filtered or unexported methods
}

SessionExecutor wraps an util.SQLErrorExecutor with getdboper

type SessionStream

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

SessionStream accepts CommonMessages and returns CommonReplies. internally it synchronizes with the schema manager and keeps open buffers for efficient writes

func NewSessionStream

func NewSessionStream(pcancel chan bool, wp *util.WorkerPool, smgr *schemaMgr, db Dber, oper *dbOper) *SessionStream

NewSessionStream returns a newly allocated SessionStream

func (*SessionStream) Cancel

func (ss *SessionStream) Cancel() error

Cancel is used when there is an error on the client-side, called to rollback all executed queries

func (*SessionStream) Close

func (ss *SessionStream) Close() error

Close is only for a normal close operation. A cancellation can only be done by Closing the parent session while the stream is still running This should be called by the same goroutine as the one calling Send

func (*SessionStream) Flush

func (ss *SessionStream) Flush() error

Flush is called when a stream finishes successfully It flushes all remaining buffers

func (*SessionStream) Send

func (ss *SessionStream) Send(cmd sessionCmd, arg interface{}) error

Send performs a type of send on the sessionstream with an arbitrary argument WARNING, sending after a close will cause a panic, and may hang

type Sessioner

type Sessioner interface {
	Do(cmd sessionCmd, arg interface{}) (*SessionStream, error)
	Close() error
}

Sessioner is an interface that wraps Do and Close

Jump to

Keyboard shortcuts

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