be

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 21 Imported by: 0

README

test

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = initDefaultBELogger()

Functions

func GenerateInnerLogger

func GenerateInnerLogger(logFileName, isJsonType, logMaxSize, logFileBackupCount, allowLogLevel string) log.Logger

func PrintResult

func PrintResult(i interface{})

func ToJson

func ToJson(i interface{}) string

Types

type BadResponseError

type BadResponseError struct {
	RespBody   string
	RespHeader map[string][]string
	HTTPCode   int
}

BadResponseError define be http bad response error

func NewBadResponseError

func NewBadResponseError(body string, header map[string][]string, httpCode int) *BadResponseError

func (BadResponseError) Error

func (e BadResponseError) Error() string

func (BadResponseError) String

func (e BadResponseError) String() string

type Client

type Client struct {
	Endpoint string
	UserName string
	PassWord string

	EnableMetric bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, userName string, passWord string) *Client

func (*Client) InitMetrics

func (c *Client) InitMetrics()

func (*Client) Read

func (c *Client) Read(readRequest ReadRequest) (*Response, error)

func (*Client) WithConnectionSize

func (c *Client) WithConnectionSize(connectionCount int) *Client

func (*Client) WithRequestTimeout

func (c *Client) WithRequestTimeout(timeout time.Duration) *Client

WithRequestTimeout with custom timeout for a request

func (*Client) Write

func (c *Client) Write(writeRequest WriteRequest) (*Response, error)

type ClientError

type ClientError struct {
	Message string `json:"errorMessage"`
}

ClientError defines be client error

func NewClientError

func NewClientError(err error) *ClientError

NewClientError new client error

func (ClientError) Error

func (e ClientError) Error() string

func (ClientError) String

func (e ClientError) String() string

type ExposureClause

type ExposureClause struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

func NewExposureClause

func NewExposureClause(values []string) *ExposureClause

func (*ExposureClause) BuildParams

func (c *ExposureClause) BuildParams() string

type FbReadParser

type FbReadParser struct {
}

type Filter

type Filter interface {
	GetConditionValue() string
	Validate() error
}

type FilterClause

type FilterClause struct {
	Filter Filter `json:"filter"`
	Clause string `json:"clause"`
}

func NewFilterClause

func NewFilterClause(filter Filter) *FilterClause

func (*FilterClause) BuildParams

func (c *FilterClause) BuildParams() string

func (*FilterClause) GetFilter

func (c *FilterClause) GetFilter() Filter

func (*FilterClause) SetClause

func (c *FilterClause) SetClause(clause string) *FilterClause

func (*FilterClause) SetFilter

func (c *FilterClause) SetFilter(filter *Filter) *FilterClause

type FilterConnector

type FilterConnector string
const (
	FilterConnectorAnd FilterConnector = "AND"
	FilterConnectorOR  FilterConnector = "OR"
)

type FilterOperator

type FilterOperator string
const (
	EQ FilterOperator = "="
	NE FilterOperator = "!="
	LT FilterOperator = "<"
	GT FilterOperator = ">"
	LE FilterOperator = "<="
	GE FilterOperator = ">="
)

type InvalidParamsError

type InvalidParamsError struct {
	Message string
}

func (InvalidParamsError) Error

func (e InvalidParamsError) Error() string

func (InvalidParamsError) String

func (e InvalidParamsError) String() string

type JsonReadParser

type JsonReadParser struct {
}

type MatchItem

type MatchItem struct {
	FieldNames  []string        `json:"field_names"`
	FieldValues [][]interface{} `json:"field_values"`
}

type Metrics

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

type MultiFilter

type MultiFilter struct {
	Filters   []Filter        `json:"filters"`
	Connector FilterConnector `json:"connector"`
}

func (*MultiFilter) GetConditionValue

func (f *MultiFilter) GetConditionValue() string

func (*MultiFilter) Validate

func (f *MultiFilter) Validate() error

type ReadParser

type ReadParser interface {
	// contains filtered or unexported methods
}

type ReadRequest

type ReadRequest struct {
	ReturnCount    int               `json:"return_count"`
	BizName        string            `json:"biz_name"`
	FilterClause   *FilterClause     `json:"filter_clause"`
	RecallParams   []RecallParam     `json:"recall_params"`
	ExposureClause *ExposureClause   `json:"exposure_clause"`
	QueryParams    map[string]string `json:"query_params"`
	IsRawRequest   bool              `json:"is_raw_request"`
	OutFmt         string            `json:"out_fmt"`
}

func NewReadRequest

func NewReadRequest(bizName string, returnCount int) *ReadRequest

func (*ReadRequest) AddQueryParam

func (r *ReadRequest) AddQueryParam(key string, value string) *ReadRequest

func (*ReadRequest) AddRecallParam

func (r *ReadRequest) AddRecallParam(param *RecallParam) *ReadRequest

func (*ReadRequest) BuildUri

func (r *ReadRequest) BuildUri() url.URL

func (*ReadRequest) SetBizName

func (r *ReadRequest) SetBizName(bizName string) *ReadRequest

func (*ReadRequest) SetFilterClause

func (r *ReadRequest) SetFilterClause(clause *FilterClause) *ReadRequest

func (*ReadRequest) SetQueryParams

func (r *ReadRequest) SetQueryParams(params map[string]string) *ReadRequest

func (*ReadRequest) SetRecallParams

func (r *ReadRequest) SetRecallParams(recallParams []RecallParam) *ReadRequest

func (*ReadRequest) SetReturnCount

func (r *ReadRequest) SetReturnCount(returnCount int) *ReadRequest

func (*ReadRequest) Validate

func (r *ReadRequest) Validate() error

type ReadResult

type ReadResult struct {
	ErrorCode    int       `json:"error_code"`
	ErrorMessage string    `json:"error_message"`
	MatchItems   MatchItem `json:"match_items"`
}

type RecallParam

type RecallParam struct {
	RecallName   string        `json:"recall_name"`
	TriggerItems []string      `json:"trigger_items"`
	RecallType   RecallType    `json:"recall_type"`
	ReturnCount  int           `json:"return_count"`
	ScorerClause *ScorerClause `json:"scorer_clause"`
}

func NewRecallParam

func NewRecallParam() *RecallParam

func (*RecallParam) SetRecallName

func (p *RecallParam) SetRecallName(name string) *RecallParam

func (*RecallParam) SetRecallType

func (p *RecallParam) SetRecallType(recallType RecallType) *RecallParam

func (*RecallParam) SetReturnCount

func (p *RecallParam) SetReturnCount(returnCount int) *RecallParam

func (*RecallParam) SetScorerClause

func (p *RecallParam) SetScorerClause(clause *ScorerClause) *RecallParam

func (*RecallParam) SetTriggerItems

func (p *RecallParam) SetTriggerItems(items []string) *RecallParam

func (*RecallParam) Validate

func (p *RecallParam) Validate() error

type RecallType

type RecallType string
const (
	RecallTypeX2I    RecallType = "X2I"
	RecallTypeVector RecallType = "Vector"
)

type Response

type Response struct {
	Result Result `json:"result"`
}

func NewResponse

func NewResponse(result Result) *Response

type Result

type Result struct {
	MatchItems *MatchItem `json:"match_items"`
}

type ScorerClause

type ScorerClause struct {
	Clause string `json:"clause"`
}

func NewScorerClause

func NewScorerClause(clause string) *ScorerClause

type SingleFilter

type SingleFilter struct {
	Left     string         `json:"left"`
	Operator FilterOperator `json:"operator"`
	Right    string         `json:"right"`
}

func (*SingleFilter) GetConditionValue

func (f *SingleFilter) GetConditionValue() string

func (*SingleFilter) Validate

func (f *SingleFilter) Validate() error

type WriteRequest

type WriteRequest struct {
	WriteType   WriteType           `json:"write_type"`
	TableName   string              `json:"table_name"`
	Contents    []map[string]string `json:"contents"`
	PrimaryKey  string              `json:"primary_key"`
	QueryParams map[string]string   `json:"query_params"`
}

func NewWriteRequest

func NewWriteRequest(writeType WriteType, tableName string, primaryKey string, contents []map[string]string) *WriteRequest

func (*WriteRequest) AddQueryParam

func (r *WriteRequest) AddQueryParam(key string, value string) *WriteRequest

func (*WriteRequest) BuildUri

func (r *WriteRequest) BuildUri(index int) url.URL

func (*WriteRequest) SetQueryParams

func (r *WriteRequest) SetQueryParams(params map[string]string) *WriteRequest

func (*WriteRequest) Validate

func (r *WriteRequest) Validate() error

type WriteResult

type WriteResult struct {
	Errno int `json:"errno"`
}

type WriteType

type WriteType string
const (
	WriteTypeAdd    WriteType = "ADD"
	WriteTypeDelete WriteType = "DELETE"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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