client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedSchemaHandler added in v0.0.2

type CachedSchemaHandler struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

CachedSchemaHandler handles schema and enum requests with cache

func NewCachedSchemaHandler added in v0.0.2

func NewCachedSchemaHandler(logger *zap.SugaredLogger, scope tally.Scope, schamaFetcher SchemaFetcher) *CachedSchemaHandler

NewCachedSchemaHandler creates a new cached schema handler

func (*CachedSchemaHandler) FetchAllSchema added in v0.0.2

func (cf *CachedSchemaHandler) FetchAllSchema() error

FetchAllSchema fetch all schemas

func (*CachedSchemaHandler) FetchSchema added in v0.0.2

func (cf *CachedSchemaHandler) FetchSchema(tableName string) (*TableSchema, error)

FetchSchema fetchs the schema of given table name

func (*CachedSchemaHandler) FetchSchemas added in v0.0.2

func (cf *CachedSchemaHandler) FetchSchemas()

FetchSchemas fetch schemas in schemas of CachedSchemaHandler

func (*CachedSchemaHandler) PrepareEnumCases added in v0.0.2

func (cf *CachedSchemaHandler) PrepareEnumCases(tableName, columnName string, enumCases []string) error

PrepareEnumCases prepares enum cases

func (*CachedSchemaHandler) Start added in v0.0.2

func (cf *CachedSchemaHandler) Start(interval int)

Start starts the CachedSchemaHandler, if interval > 0, will start periodical refresh

func (*CachedSchemaHandler) TranslateEnum added in v0.0.2

func (cf *CachedSchemaHandler) TranslateEnum(tableName string, columnID int, value interface{}, caseInsensitive bool) (enumID int, err error)

TranslateEnum translates given enum value to its enumID

type Connector

type Connector interface {
	// Insert inserts rows to ares
	// returns number of rows inserted and error.
	// updateModes are optional, if ignored for all columns, no need to set
	// if set, then all columns needs to be set
	Insert(tableName string, columnNames []string, rows []Row, updateModes ...memCom.ColumnUpdateMode) (int, error)
	// Close the connection
	Close()
}

Connector is the connector interface for ares.

type ConnectorConfig

type ConnectorConfig struct {
	// Address is in the format of host:port
	Address string `yaml:"address" json:"address"`
	// DeviceChoosingTimeout value is the request timeout in seconds for http calls
	// if <= 0, will use default
	Timeout int `yaml:"timeout" json:"timeout"`
	// SchemaRefreshInterval is the interval in seconds for the connector to
	// fetch and refresh schema from ares
	// if <= 0, will use default
	SchemaRefreshInterval int `yaml:"schemaRefreshInterval" json:"schemaRefreshInterval"`
}

ConnectorConfig holds the configurations for ares Connector.

func (ConnectorConfig) NewConnector

func (cfg ConnectorConfig) NewConnector(logger *zap.SugaredLogger, metricScope tally.Scope) Connector

NewConnector returns a new ares Connector

type Row

type Row []interface{}

Row represents a row of insert data.

type SchemaFetcher added in v0.0.2

type SchemaFetcher interface {
	// FetchAllSchemas fetches all schemas
	FetchAllSchemas() ([]*metaCom.Table, error)
	// FetchSchema fetch one schema for given table
	FetchSchema(table string) (*metaCom.Table, error)
	// FetchAllEnums fetches all enums for given table and column
	FetchAllEnums(tableName string, columnName string) ([]string, error)
	// ExtendEnumCases extends enum cases to given table column
	ExtendEnumCases(tableName, columnName string, enumCases []string) ([]int, error)
}

SchemaFetcher is the interface for fetch schema and enums

func NewHttpSchemaFetcher added in v0.0.2

func NewHttpSchemaFetcher(httpClient http.Client, address string, scope tally.Scope) SchemaFetcher

NewHttpSchemaFetcher creates a new http schema fetcher

type TableSchema added in v0.0.2

type TableSchema struct {
	Table *metaCom.Table
	// maps from column name to columnID for convenience
	ColumnDict map[string]int
}

type UpsertBatchBuilder added in v0.0.2

type UpsertBatchBuilder interface {
	PrepareUpsertBatch(tableName string, columnNames []string, updateModes []memCom.ColumnUpdateMode, rows []Row) ([]byte, int, error)
}

UpsertBatchBuilder is an interface of upsertBatch on client side

func NewUpsertBatchBuilderImpl added in v0.0.2

func NewUpsertBatchBuilderImpl(logger *zap.SugaredLogger, scope tally.Scope, schemaHandler *CachedSchemaHandler) UpsertBatchBuilder

type UpsertBatchBuilderImpl added in v0.0.2

type UpsertBatchBuilderImpl struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UpsertBatchBuilderImpl implements interface UpsertBatchBuilder

func (*UpsertBatchBuilderImpl) PrepareUpsertBatch added in v0.0.2

func (u *UpsertBatchBuilderImpl) PrepareUpsertBatch(tableName string, columnNames []string,
	updateModes []memCom.ColumnUpdateMode, rows []Row) ([]byte, int, error)

PrepareUpsertBatch prepares the upsert batch for upsert, returns upsertBatch byte array, number of rows in upsert batch and error.

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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