clickhouse

package module
v0.0.0-...-3cea427 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 8 Imported by: 1

README

clickhouse

clickhouse binary batching proxy and alternative binary client implementation

Documentation

Index

Constants

View Source
const (
	DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE          = 54058
	DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060
)

Variables

This section is empty.

Functions

func GetDatabase

func GetDatabase(opts ...ClientOption) string

Types

type Agent

type Agent struct {
	Name string
	Ver  Ver
}

type ApplyToCredentialser

type ApplyToCredentialser interface {
	ApplyToCredentials(*Credentials) error
}

type BaseOption

type BaseOption string

func OptFunc

func OptFunc(d int) BaseOption

func (BaseOption) String

func (o BaseOption) String() string

type Block

type Block struct {
	Table string

	Rows int
	Cols []Column
}

func (*Block) DataSize

func (b *Block) DataSize() (size int64)

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

func (*Block) TlogAppend

func (b *Block) TlogAppend(e *wire.Encoder, buf []byte) []byte

type Client

type Client interface {
	NextPacket(context.Context) (ServerPacket, error)

	SendQuery(context.Context, *Query) (QueryMeta, error)
	CancelQuery(context.Context) error

	SendBlock(ctx context.Context, b *Block, compr bool) error
	RecvBlock(ctx context.Context, compr bool) (b *Block, err error)

	RecvException(context.Context) error
	RecvProgress(context.Context) (Progress, error)
	RecvProfileInfo(context.Context) (ProfileInfo, error)
}

type ClientOption

type ClientOption interface {
	fmt.Stringer
}

func WithCredentials

func WithCredentials(c Credentials) ClientOption

func WithDatabase

func WithDatabase(db string) ClientOption

type ClientPacket

type ClientPacket int
const (
	ClientHello ClientPacket = iota
	ClientQuery
	ClientData
	ClientCancel
	ClientPing
)

type ClientPool

type ClientPool interface {
	Get(context.Context, ...ClientOption) (Client, error)
	Put(context.Context, Client, error) error

	io.Closer
}

type Column

type Column struct {
	Name string
	Type string

	RawData []byte
}

type Credentials

type Credentials struct {
	Database string
	User     string
	Password string
}

type CredentialsOption

type CredentialsOption struct {
	BaseOption
	F func(*Credentials) error
}

func (CredentialsOption) ApplyToCredentials

func (o CredentialsOption) ApplyToCredentials(c *Credentials) (err error)

type Exception

type Exception struct {
	Code       int32
	Name       string
	Message    string
	StackTrace string

	Cause *Exception
}

func (*Exception) Error

func (e *Exception) Error() string

type Pinger

type Pinger interface {
	SendPing(context.Context) error
}

type ProfileInfo

type ProfileInfo struct {
	Rows   uint64
	Blocks uint64
	Bytes  uint64

	AppliedLimit        uint64
	RowsBeforeLimit     uint64
	CalcRowsBeforeLimit uint64
}

type Progress

type Progress struct {
	Rows      uint64
	Bytes     uint64
	TotalRows uint64
}

type Query

type Query struct {
	Query string

	ID       string
	QuotaKey string

	Compressed bool

	Client Agent
}

func (*Query) Copy

func (q *Query) Copy() *Query

func (*Query) IsExec

func (q *Query) IsExec() bool

func (*Query) IsInsert

func (q *Query) IsInsert() bool

type QueryMeta

type QueryMeta []Column

func (QueryMeta) TlogAppend

func (m QueryMeta) TlogAppend(e *wire.Encoder, b []byte) []byte

type Server

type Server interface {
	Serve(context.Context, net.Listener) error
	HandleConn(context.Context, net.Conn) error
	HandleRequest(context.Context, ServerConn, ...ClientOption) error

	io.Closer
}

type ServerConn

type ServerConn interface {
	NextPacket(context.Context) (ClientPacket, error)

	RecvQuery(context.Context) (*Query, error)
	SendQueryMeta(ctx context.Context, m QueryMeta, compr bool) error

	SendBlock(ctx context.Context, b *Block, compr bool) error
	RecvBlock(ctx context.Context, compr bool) (b *Block, err error)

	SendEndOfStream(context.Context) error

	SendException(context.Context, error) error
	SendProgress(context.Context, Progress) error
	SendProfileInfo(context.Context, ProfileInfo) error
}

type ServerPacket

type ServerPacket int
const (
	ServerHello ServerPacket = iota
	ServerData
	ServerException
	ServerProgress
	ServerPong
	ServerEndOfStream
	ServerProfileInfo
	ServerTotals
	ServerExtremes
)

type Ver

type Ver [3]int

Directories

Path Synopsis
cmd
click command

Jump to

Keyboard shortcuts

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