tars

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: BSD-3-Clause Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOTIFY_NORMAL = 0
	NOTIFY_WARN   = 1
	NOTIFY_ERROR  = 2
)
View Source
const (
	STAT_SUCCESS = iota
	STAT_FAILED
)
View Source
const (

	//TarsVersion is tars version
	TarsVersion string = "1.1.2"

	//AcceptTimeout accept timeout,defaultvalue is 500 milliseconds
	AcceptTimeout = 500
	//ReadTimeout zero millisecond for not set read deadline for Conn (better  performance)
	ReadTimeout = 0
	//WriteTimeout zero millisecond for not set write deadline for Conn (better performance)
	WriteTimeout = 0
	//HandleTimeout zero millisecond for not set deadline for invoke user interface (better performance)
	HandleTimeout = 0
	//IdleTimeout idle timeout,defaultvalue is 600000 milliseconds
	IdleTimeout = 600000
	//ZombileTimeout zombile timeout,defaultvalue is 10000 milliseconds
	ZombileTimeout = 10000
	//QueueCap queue gap
	QueueCap int = 10000000

	//ClientQueueLen client queue length
	ClientQueueLen int = 10000
	//ClientIdleTimeout client idle timeout,defaultvalue is 600000 milliseconds
	ClientIdleTimeout = 600000
	//ClientReadTimeout client read timeout,defaultvalue is 100 milliseconds
	ClientReadTimeout = 100
	//ClientWriteTimeout client write timeout,defaultvalue is 3000 milliseconds
	ClientWriteTimeout = 3000
	//ReqDefaultTimeout request default timeout
	ReqDefaultTimeout int32 = 3000
	//ClientDialTimeout connection dial timeout
	ClientDialTimeout = 3000
	//ObjQueueMax obj queue max number
	ObjQueueMax int32 = 100000

	//PropertyReportInterval property report interval,defaultvalue is 10000 milliseconds
	PropertyReportInterval = 10000
	//StatReportInterval stat report interval,defaultvalue is 10000 milliseconds
	StatReportInterval = 10000
	// StatReportChannelBufLen stat report channel len
	StatReportChannelBufLen = 100000

	//MainLoopTicker main loop ticker,defaultvalue is 10000 milliseconds
	MainLoopTicker = 10000

	//AdapterProxyTicker adapter proxy ticker,defaultvalue is 10000 milliseconds
	AdapterProxyTicker = 10000
	//AdapterProxyResetCount adapter proxy reset count
	AdapterProxyResetCount int = 5

	//AsyncInvokeTimeout async invoke timeout
	AsyncInvokeTimeout int = 3000

	//TCPReadBuffer tcp read buffer length
	TCPReadBuffer = 128 * 1024 * 1024
	//TCPWriteBuffer tcp write buffer length
	TCPWriteBuffer = 128 * 1024 * 1024
	//TCPNoDelay set tcp no delay
	TCPNoDelay = false

	//GracedownTimeout set timeout (milliseconds) for grace shutdown
	GracedownTimeout = 60000

	//MaxPackageLength maximum length of the request
	MaxPackageLength = 10485760
)

Variables

View Source
var MaxInvoke int32

MaxInvoke number of worker routine to handle client request zero means no control, just one goroutine for a client request. runtime.NumCPU() usually best performance in the benchmark.

View Source
var (
	// ReportStat set the default stater(default is `ReportStatFromClient`).
	ReportStat reportStatFunc = ReportStatFromClient
)
View Source
var ServerConfigPath string

ServerConfigPath is the path of server config

View Source
var TLOG = rogger.GetLogger("TLOG")

TLOG is the logger for tars framework.

Functions

func AddHttpServant

func AddHttpServant(mux *TarsHttpMux, obj string)

AddHttpServant add http servant handler with default exceptionStatusChecker for obj.

func AddHttpServantWithExceptionStatusChecker

func AddHttpServantWithExceptionStatusChecker(mux *TarsHttpMux, obj string, exceptionStatusChecker func(int) bool)

AddHttpServantWithExceptionStatusChecker add http servant handler with exceptionStatusChecker for obj.

func AddServant

func AddServant(v dispatch, f interface{}, obj string)

AddServant add dispatch and interface for object.

func AddServantWithContext

func AddServantWithContext(v dispatch, f interface{}, obj string)

AddServantWithContext add dispatch and interface for object, which have ctx,context

func AddServantWithProtocol

func AddServantWithProtocol(proto transport.ServerProtocol, obj string)

AddServantWithProtocol adds a servant with protocol and obj

func CheckPanic

func CheckPanic()

//////////////////////////////////////////////////////////////////////////// CheckPanic used to dump stack info to file when catch panic

func DefaultExceptionStatusChecker

func DefaultExceptionStatusChecker(statusCode int) bool

DefaultExceptionStatusChecker Default Exception Status Checker

func GetClientConfig

func GetClientConfig() *clientConfig

GetClientConfig Get client config

func GetDayLogger

func GetDayLogger(name string, numDay int) *rogger.Logger

GetDayLogger Get a logger roll by day

func GetErrorCode

func GetErrorCode(err error) int32

GetErrorCode returns the error code

func GetHourLogger

func GetHourLogger(name string, numHour int) *rogger.Logger

GetHourLogger Get a logger roll by hour

func GetLogger

func GetLogger(name string) *rogger.Logger

GetLogger Get a logger

func GetRemoteLogger

func GetRemoteLogger(name string) *rogger.Logger

GetRemoteLogger returns a remote logger

func GetServerConfig

func GetServerConfig() *serverConfig

GetServerConfig Get server config

func Init

func Init()

Init need to be called first in some situation: like GetServerConfig() and GetClientConfig()

func RegisterAdmin

func RegisterAdmin(name string, fn adminFn)

RegisterAdmin register admin functions

func RegisterClientFilter

func RegisterClientFilter(f ClientFilter)

RegisterClientFilter registers the Client filter , and will be executed in every request.

func RegisterDispatchReporter

func RegisterDispatchReporter(f DispatchReporter)

RegisterDispatchReporter registers the server dispatch reporter

func RegisterPostClientFilter

func RegisterPostClientFilter(f ClientFilter)

RegisterPostClientFilter registers the client filter, and will be executed in order after every request

func RegisterPostServerFilter

func RegisterPostServerFilter(f ServerFilter)

RegisterPostServerFilter registers the server filter, executed in order after every request

func RegisterPreClientFilter

func RegisterPreClientFilter(f ClientFilter)

RegisterPreClientFilter registers the client filter, and will be executed in order before every request

func RegisterPreServerFilter

func RegisterPreServerFilter(f ServerFilter)

RegisterPreServerFilter registers the server filter, executed in order before every request

func RegisterServerFilter

func RegisterServerFilter(f ServerFilter)

RegisterServerFilter register the server filter.

func ReportAvg

func ReportAvg(key string, i int)

ReportAvg avg report

func ReportCount

func ReportCount(key string, i int)

ReportCount count report

func ReportDistr

func ReportDistr(key string, in []int, i int)

ReportDistr distr report

func ReportMax

func ReportMax(key string, i int)

ReportMax max report

func ReportMin

func ReportMin(key string, i int)

ReportMin min report

func ReportNotifyInfo

func ReportNotifyInfo(level int32, info string)

ReportNotifyInfo reports notify information with level and info

func ReportStatBase

func ReportStatBase(head *statf.StatMicMsgHead, body *statf.StatMicMsgBody, FromServer bool)

ReportStatBase is base method for report statitics.

func ReportStatFromClient

func ReportStatFromClient(msg *Message, succ int32, timeout int32, exec int32)

ReportStatFromClient report the statics from client.

func ReportStatFromServer

func ReportStatFromServer(InterfaceName, MasterName string, ReturnValue int32, TotalRspTime int64)

ReportStatFromServer reports statics from server side.

func ReportSum

func ReportSum(key string, i int)

ReportSum sum report

func Run

func Run()

Run the application

func UseClientFilterMiddleware

func UseClientFilterMiddleware(cfm ...ClientFilterMiddleware)

UseClientFilterMiddleware uses the client filter middleware.

func UseServerFilterMiddleware

func UseServerFilterMiddleware(sfm ...ServerFilterMiddleware)

UserServerFilterMiddleware uses the server filter middleware.

Types

type AdapterProxy

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

AdapterProxy : Adapter proxy

func NewAdapterProxy

func NewAdapterProxy(point *endpointf.EndpointF, comm *Communicator) *AdapterProxy

NewAdapterProxy : Construct an adapter proxy

func (*AdapterProxy) Close

func (c *AdapterProxy) Close()

Close : Close the client

func (*AdapterProxy) GetPoint

func (c *AdapterProxy) GetPoint() *endpointf.EndpointF

GetPoint : Get an endpoint

func (*AdapterProxy) ParsePackage

func (c *AdapterProxy) ParsePackage(buff []byte) (int, int)

ParsePackage : Parse packet from bytes

func (*AdapterProxy) Recv

func (c *AdapterProxy) Recv(pkg []byte)

Recv : Recover read channel when closed for timeout

func (*AdapterProxy) Send

func (c *AdapterProxy) Send(req *requestf.RequestPacket) error

Send : Send packet

type Admin

type Admin struct {
}

Admin struct

func (*Admin) Notify

func (a *Admin) Notify(command string) (string, error)

Notify handler for cmds from admin

func (*Admin) Shutdown

func (a *Admin) Shutdown() error

Shutdown shutdown all servant by admin

type AppCache

type AppCache struct {
	TarsVersion string
	ModifyTime  string
	LogLevel    string
	ObjCaches   []ObjCache
}

func GetAppCache

func GetAppCache() AppCache

type Avg

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

Avg for counting average for the report value.

func NewAvg

func NewAvg() *Avg

NewAvg new and init the average struct.

func (*Avg) Enum

func (a *Avg) Enum() ReportPolicy

Enum return the report policy

func (*Avg) Get

func (a *Avg) Get() (out string)

Get gets the result of the average counting.

func (*Avg) Set

func (a *Avg) Set(in int)

Set sets the value for the average counting.

type ClientFilter

type ClientFilter func(ctx context.Context, msg *Message, invoke Invoke, timeout time.Duration) (err error)

ClientFilter is used for filter request & response for client, for implementing plugins like opentracing

type ClientFilterMiddleware

type ClientFilterMiddleware func(next ClientFilter) ClientFilter

ClientFilterMiddleware is used for add multiple filter middleware for client, for using multiple filter such as breaker, rate limit and trace.

type Communicator

type Communicator struct {
	Client *clientConfig
	// contains filtered or unexported fields
}

Communicator struct

func NewCommunicator

func NewCommunicator() *Communicator

NewCommunicator returns a new communicator. A Communicator is used for communicating with the server side which should only init once and be global!!!

func (*Communicator) GetLocator

func (c *Communicator) GetLocator() string

GetLocator returns locator as string

func (*Communicator) GetProperty

func (c *Communicator) GetProperty(key string) (string, bool)

GetProperty returns communicator property value as string and true for key, or empty string and false for not exists key

func (*Communicator) GetPropertyBool

func (c *Communicator) GetPropertyBool(key string) (bool, bool)

GetPropertyBool returns communicator property value as bool and true for key, or false and false for not exists key

func (*Communicator) GetPropertyInt

func (c *Communicator) GetPropertyInt(key string) (int, bool)

GetPropertyInt returns communicator property value as int and true for key, or 0 and false for not exists key

func (*Communicator) SetLocator

func (c *Communicator) SetLocator(obj string)

SetLocator sets locator with obj

func (*Communicator) SetProperty

func (c *Communicator) SetProperty(key string, value interface{})

SetProperty sets communicator property with a string key and an interface value. var comm *tars.Communicator comm = tars.NewCommunicator() e.g. comm.SetProperty("locator", "tars.tarsregistry.QueryObj@tcp -h ... -p ...")

func (*Communicator) StringToProxy

func (c *Communicator) StringToProxy(servant string, p ProxyPrx)

StringToProxy sets the servant of ProxyPrx p with a string servant

type Count

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

Count is for counting the total of reporting

func NewCount

func NewCount() *Count

NewCount new and init the counting struct.

func (*Count) Enum

func (c *Count) Enum() ReportPolicy

Enum return the report policy

func (*Count) Get

func (c *Count) Get() (out string)

Get gets the total times of the reporting values.

func (*Count) Set

func (c *Count) Set(in int)

Set sets the value for counting.

type Dispatch

type Dispatch func(context.Context, interface{}, *requestf.RequestPacket, *requestf.ResponsePacket, bool) error

Dispatch server side Dispatch

type DispatchReporter

type DispatchReporter func(ctx context.Context, req []interface{}, rsp []interface{}, returns []interface{})

DispatchReporter is the reporter in server-side dispatch, and will be used in logging

func GetDispatchReporter

func GetDispatchReporter() DispatchReporter

GetDispatchReporter returns the dispatch reporter

type Distr

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

Distr is used for counting the distribution of the reporting values.

func NewDistr

func NewDistr(in []int) (d *Distr)

NewDistr new and int the Distr

func (*Distr) Enum

func (d *Distr) Enum() ReportPolicy

Enum return the report policy

func (*Distr) Get

func (d *Distr) Get() string

Get get the distribution of the reporting values.

func (*Distr) Set

func (d *Distr) Set(in int)

Set sets the value for counting distribution.

type EndpointManager

type EndpointManager interface {
	SelectAdapterProxy(msg *Message) (*AdapterProxy, bool)
	GetAllEndpoint() []*endpoint.Endpoint
	// contains filtered or unexported methods
}

EndpointManager interface of naming system

func GetManager

func GetManager(comm *Communicator, objName string) EndpointManager

GetManager return a endpoint manager from global endpoint manager

type Error

type Error struct {
	Code    int32
	Message string
}

Error is the type of rpc error with error code

func Errorf

func Errorf(code int32, format string, args ...interface{}) *Error

Errorf return the tars.Error instance

func (*Error) Error

func (e *Error) Error() string

Error returns the error message

type HashType

type HashType int

HashType is the hash type

const (
	ModHash HashType = iota
	ConsistentHash
)

HashType enum

type Invoke

type Invoke func(ctx context.Context, msg *Message, timeout time.Duration) (err error)

Invoke is used for Invoke tars server service

type Max

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

Max struct is for counting the Max value for the reporting value.

func NewMax

func NewMax() *Max

NewMax new and init the Max struct.

func (*Max) Enum

func (m *Max) Enum() ReportPolicy

Enum return the report policy

func (*Max) Get

func (m *Max) Get() (out string)

Get gets the max value.

func (*Max) Set

func (m *Max) Set(in int)

Set sets a value for counting max.

type Message

type Message struct {
	Req  *requestf.RequestPacket
	Resp *requestf.ResponsePacket

	Ser *ServantProxy
	Adp *AdapterProxy

	BeginTime int64
	EndTime   int64
	Status    int32
	// contains filtered or unexported fields
}

Message is a struct contains servant information

func (*Message) Cost

func (m *Message) Cost() int64

Cost calculate the cost time

func (*Message) End

func (m *Message) End()

End define the endtime

func (*Message) Init

func (m *Message) Init()

Init define the begintime

func (*Message) SetHash

func (m *Message) SetHash(code uint32, h HashType)

SetHash set hash code

type Min

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

Min is the struct for counting the min value.

func NewMin

func NewMin() *Min

NewMin new and init the min struct.

func (*Min) Enum

func (m *Min) Enum() ReportPolicy

Enum return the report policy

func (*Min) Get

func (m *Min) Get() (out string)

Get get the min value for the Min struct.

func (*Min) Set

func (m *Min) Set(in int)

Set sets a value for counting min value.

type NodeFHelper

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

NodeFHelper is helper struct.

func (*NodeFHelper) KeepAlive

func (n *NodeFHelper) KeepAlive(adapter string)

KeepAlive sends the keepalive pacakage to the node.

func (*NodeFHelper) ReportVersion

func (n *NodeFHelper) ReportVersion(version string)

ReportVersion report the tars version to the node.

func (*NodeFHelper) SetNodeInfo

func (n *NodeFHelper) SetNodeInfo(comm *Communicator, node string, app string, server string, container string)

SetNodeInfo sets node information with communicator, node name, app name, server and container name

type NotifyHelper

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

NotifyHelper is the helper struct for the Notify service.

func (*NotifyHelper) ReportNotifyInfo

func (n *NotifyHelper) ReportNotifyInfo(level int32, info string)

ReportNotifyInfo reports notify information with level and info

func (*NotifyHelper) SetNotifyInfo

func (n *NotifyHelper) SetNotifyInfo(comm *Communicator, notify string, app string, server string, container string)

SetNotifyInfo sets the communicator's notify info with communicator, notify name, app name, server name, and container name

type ObjCache

type ObjCache struct {
	Name    string
	Locator string

	Endpoints         []endpointf.EndpointF
	InactiveEndpoints []endpointf.EndpointF
}

type PanicFunc

type PanicFunc func(interface{}) bool

////////////////////////////////////////////////////////////////////////////

var (
	FPanic PanicFunc
)

type PropertyReport

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

PropertyReport property report struct

func CreatePropertyReport

func CreatePropertyReport(key string, argvs ...ReportMethod) *PropertyReport

CreatePropertyReport creats the property report instance with the key.

func GetPropertyReport

func GetPropertyReport(key string) *PropertyReport

GetPropertyReport gets the property report instance with the key.

func (*PropertyReport) Report

func (p *PropertyReport) Report(in int)

Report reports a value.

type PropertyReportHelper

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

PropertyReportHelper is helper struct for property report.

var ProHelper *PropertyReportHelper

ProHelper is global PropertyReportHelper instance

func (*PropertyReportHelper) AddToReport

func (p *PropertyReportHelper) AddToReport(pr *PropertyReport)

AddToReport adds the user's PropertyReport to the PropertyReportHelper

func (*PropertyReportHelper) Init

func (p *PropertyReportHelper) Init(comm *Communicator, node string)

Init inits the PropertyReportHelper

func (*PropertyReportHelper) ReportToServer

func (p *PropertyReportHelper) ReportToServer()

ReportToServer report to the remote propertyreport server.

func (*PropertyReportHelper) Run

func (p *PropertyReportHelper) Run()

Run start the properting report goroutine.

type ProxyPrx

type ProxyPrx interface {
	SetServant(s.Servant)
}

ProxyPrx interface

type RConf

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

RConf struct for getting remote config.

func NewRConf

func NewRConf(app string, server string, path string) *RConf

NewRConf init a Rconf, path should be getting from GetServerConfig().BasePath

func (*RConf) GetConfig

func (c *RConf) GetConfig(filename string) (config string, err error)

GetConfig gets the remote config and save it to the path, also return the content.

func (*RConf) GetConfigList

func (c *RConf) GetConfigList() (flist []string, err error)

GetConfigList is discarded.

type RemoteTimeWriter

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

RemoteTimeWriter writer for writing remote log.

func NewRemoteTimeWriter

func NewRemoteTimeWriter() *RemoteTimeWriter

NewRemoteTimeWriter new and init RemoteTimeWriter

func (*RemoteTimeWriter) EnablePrefix

func (rw *RemoteTimeWriter) EnablePrefix(hasAppNamePrefix bool)

EnablePrefix puts prefix before logs.

func (*RemoteTimeWriter) EnableSqarewrapper

func (rw *RemoteTimeWriter) EnableSqarewrapper(hasSquareBracket bool)

EnableSqarewrapper enables SquareBracket wrapper for the logs.

func (*RemoteTimeWriter) EnableSufix

func (rw *RemoteTimeWriter) EnableSufix(hasSufix bool)

EnableSufix puts sufix after logs.

func (*RemoteTimeWriter) InitFormat

func (rw *RemoteTimeWriter) InitFormat(s string)

InitFormat sets the log format.

func (*RemoteTimeWriter) InitServerInfo

func (rw *RemoteTimeWriter) InitServerInfo(app string, server string, filename string, setdivision string)

InitServerInfo init the remote log server info.

func (*RemoteTimeWriter) NeedPrefix

func (rw *RemoteTimeWriter) NeedPrefix() bool

NeedPrefix return if need prefix for the logger.

func (*RemoteTimeWriter) SetFileNameConcatStr

func (rw *RemoteTimeWriter) SetFileNameConcatStr(s string)

SetFileNameConcatStr sets the filename concat string.

func (*RemoteTimeWriter) SetLogType

func (rw *RemoteTimeWriter) SetLogType(logType string)

SetLogType sets the log type.

func (*RemoteTimeWriter) SetPrefix

func (rw *RemoteTimeWriter) SetPrefix(enable bool)

SetPrefix set if need prefix for the logger.

func (*RemoteTimeWriter) SetSeparator

func (rw *RemoteTimeWriter) SetSeparator(s string)

SetSeparator set seprator between logs.

func (*RemoteTimeWriter) Sync2remote

func (rw *RemoteTimeWriter) Sync2remote()

Sync2remote syncs the log buffer to remote.

func (*RemoteTimeWriter) Write

func (rw *RemoteTimeWriter) Write(b []byte)

Write Writes the logs to the buffer.

type ReportMethod

type ReportMethod interface {
	Enum() ReportPolicy
	Set(int)
	Get() string
	// contains filtered or unexported methods
}

ReportMethod is the interface for all kinds of report methods.

type ReportPolicy

type ReportPolicy int

ReportPolicy is report policy

const (
	ReportPolicyUnknown ReportPolicy = iota
	ReportPolicySum                  // 1
	ReportPolicyAvg                  // 2
	ReportPolicyDistr                // 3
	ReportPolicyMax                  // 4
	ReportPolicyMin                  // 5
	ReportPolicyCount                // 6
)

func (ReportPolicy) String

func (p ReportPolicy) String() string

type ServantProxy

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

ServantProxy tars servant proxy instance

func NewServantProxy

func NewServantProxy(comm *Communicator, objName string) *ServantProxy

NewServantProxy creates and initializes a servant proxy

func (*ServantProxy) TarsSetProtocol

func (s *ServantProxy) TarsSetProtocol(proto model.Protocol)

TarsSetProtocol tars set model protocol

func (*ServantProxy) TarsSetTimeout

func (s *ServantProxy) TarsSetTimeout(t int)

TarsSetTimeout sets the timeout for client calling the server , which is in ms.

func (*ServantProxy) TarsSetVersion

func (s *ServantProxy) TarsSetVersion(iVersion int16)

TarsSetVersion set tars version

func (*ServantProxy) Tars_invoke

func (s *ServantProxy) Tars_invoke(ctx context.Context, ctype byte,
	sFuncName string,
	buf []byte,
	status map[string]string,
	reqContext map[string]string,
	resp *requestf.ResponsePacket) error

Tars_invoke is used for client inoking server.

type ServerFilter

type ServerFilter func(ctx context.Context, d Dispatch, f interface{},
	req *requestf.RequestPacket, resp *requestf.ResponsePacket, withContext bool) (err error)

ServerFilter is used for add Filter for server dispatcher ,for implementing plugins like opentracing.

type ServerFilterMiddleware

type ServerFilterMiddleware func(next ServerFilter) ServerFilter

ServerFilterMiddleware is used for add multiple filter middlewares for dispatcher, for using multiple filter such as breaker, rate limit and trace.

type StatFHelper

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

StatFHelper is helper struct for stat reporting.

var StatReport *StatFHelper

StatReport instance pointer of StatFHelper

func (*StatFHelper) Init

func (s *StatFHelper) Init(comm *Communicator, node string)

Init init the StatFHelper

func (*StatFHelper) ReportMicMsg

func (s *StatFHelper) ReportMicMsg(stStatInfo StatInfo, fromServer bool)

ReportMicMsg report the Statinfo ,from server shows whether it comes from server.

func (*StatFHelper) Run

func (s *StatFHelper) Run()

Run run stat report loop

type StatInfo

type StatInfo struct {
	Head statf.StatMicMsgHead
	Body statf.StatMicMsgBody
}

StatInfo struct contains stat info' head and body.

type Sum

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

Sum report methods.

func NewSum

func NewSum() *Sum

NewSum new and init the sum report methods.

func (*Sum) Enum

func (s *Sum) Enum() ReportPolicy

Enum return the report policy

func (*Sum) Get

func (s *Sum) Get() (out string)

Get gets the result of the sum report method.

func (*Sum) Set

func (s *Sum) Set(in int)

Set sets a value tho the sum method.

type TarsHttpConf

type TarsHttpConf struct {
	Container              string
	AppName                string
	IP                     string
	Port                   int32
	Version                string
	SetId                  string
	ExceptionStatusChecker func(int) bool
}

TarsHttpConf is configuration for tars http server.

type TarsHttpMux

type TarsHttpMux struct {
	http.ServeMux
	// contains filtered or unexported fields
}

TarsHttpMux is http.ServeMux for tars http server.

func (*TarsHttpMux) ServeHTTP

func (mux *TarsHttpMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the server for the TarsHttpMux.

func (*TarsHttpMux) SetConfig

func (mux *TarsHttpMux) SetConfig(cfg *TarsHttpConf)

SetConfig sets the cfg tho the TarsHttpMux.

type TarsProtocol

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

TarsProtocol is struct for dispatch with tars protocol.

func NewTarsProtocol

func NewTarsProtocol(dispatcher dispatch, imp interface{}, withContext bool) *TarsProtocol

NewTarsProtocol return a TarsProtocol with dipatcher and implement interface. withContext explain using context or not.

func (*TarsProtocol) DoClose

func (s *TarsProtocol) DoClose(ctx context.Context)

DoClose be called when close connection

func (*TarsProtocol) GetCloseMsg

func (s *TarsProtocol) GetCloseMsg() []byte

GetCloseMsg return a package to close connection

func (*TarsProtocol) Invoke

func (s *TarsProtocol) Invoke(ctx context.Context, req []byte) (rsp []byte)

Invoke puts the request as []byte and call the dispather, and then return the response as []byte.

func (*TarsProtocol) InvokeTimeout

func (s *TarsProtocol) InvokeTimeout(pkg []byte) []byte

InvokeTimeout indicates how to deal with timeout.

func (*TarsProtocol) ParsePackage

func (s *TarsProtocol) ParsePackage(buff []byte) (int, int)

ParsePackage parse the []byte according to the tars protocol. returns header length and package integrity condition (PACKAGE_LESS | PACKAGE_FULL | PACKAGE_ERROR)

type TarsResponseWriter

type TarsResponseWriter struct {
	http.ResponseWriter
	StatusCode int
}

TarsResponseWriter is http.ResponseWriter for tars.

func (*TarsResponseWriter) Hijack

func (w *TarsResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack add Hijack method for TarsResponseWriter

func (*TarsResponseWriter) WriteHeader

func (w *TarsResponseWriter) WriteHeader(code int)

WriteHeader is used for write the http header with the http code.

Directories

Path Synopsis
plugin
res/adminf
Package adminf comment This file war generated by tars2go 1.1 Generated from AdminF.tars
Package adminf comment This file war generated by tars2go 1.1 Generated from AdminF.tars
res/basef
Package basef comment This file war generated by tars2go 1.1 Generated from BaseF.tars
Package basef comment This file war generated by tars2go 1.1 Generated from BaseF.tars
res/configf
Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars
Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars Package configf comment This file war generated by tars2go 1.1 Generated from Config.tars
res/endpointf
Package endpointf comment This file was generated by tars2go 1.1 Generated from EndpointF.tars
Package endpointf comment This file was generated by tars2go 1.1 Generated from EndpointF.tars
res/logf
Package logf comment This file war generated by tars2go 1.1 Generated from LogF.tars Package logf comment This file war generated by tars2go 1.1 Generated from LogF.tars
Package logf comment This file war generated by tars2go 1.1 Generated from LogF.tars Package logf comment This file war generated by tars2go 1.1 Generated from LogF.tars
res/nodef
Package nodef comment This file war generated by tars2go 1.1 Generated from NodeF.tars Package nodef comment This file war generated by tars2go 1.1 Generated from NodeF.tars
Package nodef comment This file war generated by tars2go 1.1 Generated from NodeF.tars Package nodef comment This file war generated by tars2go 1.1 Generated from NodeF.tars
res/notifyf
Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars
Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars Package notifyf comment This file war generated by tars2go 1.1 Generated from NotifyF.tars
res/propertyf
Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars
Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars Package propertyf comment This file war generated by tars2go 1.1 Generated from PropertyF.tars
res/queryf
Package queryf comment This file war generated by tars2go 1.1 Generated from QueryF.tars
Package queryf comment This file war generated by tars2go 1.1 Generated from QueryF.tars
res/requestf
Package requestf comment This file war generated by tars2go 1.1 Generated from RequestF.tars Package requestf comment This file war generated by tars2go 1.1 Generated from RequestF.tars
Package requestf comment This file war generated by tars2go 1.1 Generated from RequestF.tars Package requestf comment This file war generated by tars2go 1.1 Generated from RequestF.tars
res/statf
Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars
Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars Package statf comment This file war generated by tars2go 1.1 Generated from StatF.tars
tup
tools
pb2tarsgo/protoc-gen-go/tarsrpc
Package tarsrpc outputs tars service descriptions in Go code.
Package tarsrpc outputs tars service descriptions in Go code.
util
conf
Package conf implements parse the taf config.
Package conf implements parse the taf config.
set
Package set implement
Package set implement
ssl

Jump to

Keyboard shortcuts

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