cap

package
v0.0.0-...-7662171 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressTypeHeader = "Compress-Type"
	ClusterMethodPath  = "/cluster"
)
View Source
const (
	HttpExternalClusterType = "http_cluster"
)

Variables

View Source
var Errors map[int]string = map[int]string{
	10190000: "ConnectionFromJson: Unmarshal fail",

	10190001: "Connection.DoRawQuery: request create error server: %v",
	10190002: "Connection.DoRawQuery: send request error server: %v",
	10190003: "Connection.DoRawQuery: send request read body fail server: %v",

	10190100: "ClusterConnection.CallFunc: Marshal request fail",
	10190101: "ClusterConnection.CallFunc: Compress request fail",
	10190102: "ClusterConnection.CallFunc: Send request fail",
	10190103: "ClusterConnection.CallFunc: Responce code is not 200 responce code is: %v body: %v",
	10190104: "ClusterConnection.CallFunc: Restore responce fail",
	10190106: "ClusterConnection.CallFunc: Unmarshal responce fail",

	10190200: "ClusterConnection.ToJson: marshal error",

	10190300: "HttpExternalClusterNewGenerator: unmarshal error ec.name: %v",
	10190301: "HttpExternalClusterNewGenerator: connection should be set (ClusterConnection.Connection) ec.name: %v",
	10190302: "HttpExternalClusterNewGenerator: Connection.QueryWait should be > 0 ec.name: %v value: %v",
	10190303: "HttpExternalClusterNewGenerator: Connection.Server should be set ec.name: %v",
	10190304: "HttpExternalClusterNewGenerator: encrypt AuthentificationInfo fail ec.name: %v",
	10190305: "HttpExternalClusterNewGenerator: DecryptAlg ia not correct ec.name: %v. Actual %v != Expired %v",
	10190306: "HttpExternalClusterNewGenerator: params marshal fail ec.name: %v",

	10190400: "HttpExternalClusterLoadGenerator: unmarshal error ec.name: %v",
	10190401: "HttpExternalClusterLoadGenerator: connection should be set (ClusterConnection.Connection) ec.name: %v",
	10190402: "HttpExternalClusterLoadGenerator: decrypt AuthentificationInfo fail ec.name: %v",

	10191000: "ConGroup.ToJson: marshal error",

	10191010: "ConGroupFromJson: unmarshal error",

	10191100: "ConGroup.FuncDO: send fail %v of %v",
	10191101: "ConGroup.FuncDO: Acquire semaphore send fail %v of %v",
	10191102: "ConGroup.FuncDO: Execute on cluser %v failed",
	10191103: "ConGroup.FuncDO: Priority Group with name %v does not exists",
	10191104: "ConGroup.FuncDO: Cluster with name %v does not exists; done %v of %v",

	10191130: "ConGroup.FuncDOName: Cluster with name %v does not exists",

	10191200: "QueueAddUnique: Queue `%v` does not exists",
	10191201: "QueueAddUnique: Queue `%v` get error",
	10191202: "QueueAddUnique: Queue `%v` AddUnique error",

	10191210: "QueueAddUniqueList: Queue `%v` does not exists",
	10191211: "QueueAddUniqueList: Queue `%v` get error",
	10191212: "QueueAddUniqueList: Queue `%v` AddUnique error",
}

Errors codes and description

Functions

func GenerateError

func GenerateError(key int, a ...interface{}) *mft.Error

GenerateError -

func GenerateErrorE

func GenerateErrorE(key int, err error, a ...interface{}) *mft.Error

GenerateErrorE -

func HttpExternalClusterLoadGenerator

func HttpExternalClusterLoadGenerator(
	ctx context.Context,
	compressor *compress.Generator,
	ecld *cluster.ExternalClusterLoadDescription,
	idGenerator *mft.G,
	encryptData *cluster.EncryptData,
) (cluster.Cluster, *mft.Error)

func HttpExternalClusterNewGenerator

func HttpExternalClusterNewGenerator(
	ctx context.Context,
	compressor *compress.Generator,
	ecDescription cluster.ExternalClusterDescription,
	idGenerator *mft.G,
	encryptData *cluster.EncryptData,
) (ecld *cluster.ExternalClusterLoadDescription, err *mft.Error)

func QueueAddUnique

func QueueAddUnique(queueName string,
	message []byte, externalID int64,
	externalDt int64, source string, segment int64, saveMode cn.SaveMode,
	doOnOk func(id int64),
) func(ctx context.Context, cl *cluster.ExternalAbstractCluster) (err *mft.Error)

func QueueAddUniqueList

func QueueAddUniqueList(queueName string,
	messages []queue.Message, saveMode cn.SaveMode,
	doOnOk func(ids []int64),
) func(ctx context.Context, cl *cluster.ExternalAbstractCluster) (err *mft.Error)

Types

type ClusterConnection

type ClusterConnection struct {
	Compressor *compress.Generator `json:"-"`

	Connection *Connection `json:"connection"`

	AuthentificationType string `json:"auth_type"`
	AuthentificationInfo []byte `json:"auth_info"`
	UserName             string `json:"user_name"`
	PreferContentType    string `json:"prefer_content_type"`
	SendContentType      string `json:"send_content_type"`
	// ReplaceNameForce: replace username in request to UserName
	ReplaceNameForce bool `json:"replace_name_force"`

	AuthentificationInfoDecrypt []byte `json:"-"`
}

func CreateClusterConnection

func CreateClusterConnection(compressor *compress.Generator,
	connection *Connection,
	authentificationType string,
	userName string,
	authentificationInfo json.RawMessage,
	preferContentType string,
	sendContentType string,
	replaceNameForce bool,
) (cc *ClusterConnection)

func (*ClusterConnection) CPAuthentificationInfo

func (cc *ClusterConnection) CPAuthentificationInfo()

func (*ClusterConnection) CallFunc

func (cc *ClusterConnection) CallFunc() func(ctx context.Context,
	request *cluster.RequestBody) (responce *cluster.ResponceBody)

func (*ClusterConnection) Cluster

func (*ClusterConnection) GetName

func (cc *ClusterConnection) GetName() string

func (*ClusterConnection) Init

func (cc *ClusterConnection) Init()

func (*ClusterConnection) ToJson

func (cc *ClusterConnection) ToJson() json.RawMessage

type ConGroup

type ConGroup struct {
	ConnectionsInfo map[string]*ClusterConnection `json:"connections"`

	HealthCheck map[string]bool                             `json:"-"`
	Clusters    map[string]*cluster.ExternalAbstractCluster `json:"-"`

	PriorityGroups map[string]*PriorityGroup `json:"priority_groups"`
	// contains filtered or unexported fields
}

ConGroup - Cluster connection group

func ConGroupFromJson

func ConGroupFromJson(data []byte, compressor *compress.Generator) (cg *ConGroup, err *mft.Error)

func ConGroupGenerate

func ConGroupGenerate() (cg *ConGroup)

func (*ConGroup) AddConnection

func (cg *ConGroup) AddConnection(name string, connection *ClusterConnection) *ConGroup

func (*ConGroup) FuncDO

func (cg *ConGroup) FuncDO(ctx context.Context, pgName string,
	doFunc func(ctx context.Context, c *cluster.ExternalAbstractCluster) (err *mft.Error),
	errFunc func(err *mft.Error)) (err *mft.Error)

func (*ConGroup) FuncDOName

func (cg *ConGroup) FuncDOName(ctx context.Context, conName string,
	doFunc func(ctx context.Context, c *cluster.ExternalAbstractCluster) (err *mft.Error)) (err *mft.Error)

func (*ConGroup) Init

func (cg *ConGroup) Init(compressor *compress.Generator) *ConGroup

func (*ConGroup) Ping

func (cg *ConGroup) Ping(ctx context.Context, errFunc func(err *mft.Error))

func (*ConGroup) ToJson

func (cg *ConGroup) ToJson() json.RawMessage

type Connection

type Connection struct {
	Server              string        `json:"server"`
	IgnoreSSLValidation bool          `json:"ignore_ssql_validation"`
	QueryWait           time.Duration `json:"query_wait"`

	MaxConnsPerHost     int           `json:"max_conn"`
	MaxIdleConnDuration time.Duration `json:"max_idle_duration"`
	// contains filtered or unexported fields
}

Connection - to host

func ConnectionFromJson

func ConnectionFromJson(body []byte) (c *Connection, err *mft.Error)

func CreateConnection

func CreateConnection(server string,
	ignoreSSLValidation bool,
	queryWait time.Duration,
	maxConnsPerHost int,
	maxIdleConnDuration time.Duration) (c *Connection)

func (*Connection) DoRawQuery

func (c *Connection) DoRawQuery(queryWait time.Duration, path string, headersIn map[string]string, query []byte) (body []byte, headersOut map[string]string, statusCode int, err error)

DoRawQuery do some query

func (*Connection) Init

func (c *Connection) Init()

Init connection

type PriorityGroup

type PriorityGroup struct {
	MinSuccess int                 `json:"min_success"`
	Steps      []PriorityGroupStep `json:"step"`
}

type PriorityGroupStep

type PriorityGroupStep struct {
	StepCallCount     int  `json:"call_count"`
	IgnoreHealthCheck bool `json:"ignore_health_check"`

	ConNames []string `json:"con_names"`

	NextIndex int `json:"-"`
}

Jump to

Keyboard shortcuts

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