Import path:
gitlab.soludian.com/soludian/fountain/clients/fudp_client
fudp_client
import "gitlab.soludian.com/soludian/fountain/clients/fudp_client"Index
- Constants
- Variables
- func FindUDPHandler(msg proto.Message) fudp.Handle
- func NewMessageByName(mName string) (proto.Message, error)
- func RegisterServiceHandler(x proto.Message, handler fudp.Handle)
- func WithAddr(addr string) lib_3rd.Option[Config]
- func WithClientCallbackInstance(instance ClientCallBack) lib_3rd.Option[Config]
- func WithConfig(conf *Config) lib_3rd.Option[Config]
- func WithDisableTraceInterceptor(disable ...bool) lib_3rd.Option[Config]
- func WithHostName(hostname string) lib_3rd.Option[Config]
- func WithMaxReconnectCallback(cb func()) lib_3rd.Option[Config]
- func WithProtoName(protoName string) lib_3rd.Option[Config]
- func WithSendChanSize(sendChanSize int) lib_3rd.Option[Config]
- type Client
- func (c *Client) AutoReconnect() bool
- func (c *Client) Destroy()
- func (c *Client) GetConn() *connect.Connection
- func (c *Client) GetConnection() *connect.Connection
- func (c *Client) GetRemoteAddress() string
- func (c *Client) GetRemoteName() string
- func (c *Client) GetRemoteTypeName() (name, typeS string)
- func (c *Client) GetTimer() time.Duration
- func (c *Client) OnUDPConnectionClosed(*connect.Connection)
- func (c *Client) PingLoop()
- func (c *Client) Reconnect()
- func (c *Client) Send(msg any) error
- func (c *Client) SendWithContext(ctx context.Context, msg any) error
- func (c *Client) SendWithOperatorContext(ctx context.Context, msg any, operation string) error
- func (c *Client) Serving() error
- func (c *Client) SetLocalName(name string)
- func (c *Client) SetTimer(d time.Duration)
- func (c *Client) StartTimer()
- type ClientCallBack
- type Config
- type UDPInterceptor
Constants
PackageName sets the package name
const KPackageName = "fudp_client"Variables
var GetFountainInstance = Lib.GetFountainInstancevar GetFountainManager = Lib.GetFountainManagerSử dụng khi config instance ở dạng key:value; Nếu config instance ở dạng key:array thì sử dụng hàm InstallFountainInstances Nếu config ở dạng key:array thì sẽ chỉ install config phần tử đầu tiên mà thôi
Install with config format <key>:<value>; eg: fudp_client:<value>
Usage:
config.yaml:
fudp_client:
name: default_name
...
code.go
fudp_client.InstallFountainInstance()
fudp_client.WithConfigKey("fudp_client").InstallFountainInstance()var InstallFountainInstance = Lib.InstallFountainInstanceSử dụng khi config instance ở dạng key:array<value>; Sẽ luôn cố gắng khởi tạo kể cả khi config ở dạng key:value
Install with config format <key>:array<value>; eg: fudp_client:array<value>
Usage:
config.yaml:
fudp_client:
- name: default_name
...
code.go
fudp_client.InstallFountainInstances()
fudp_client.WithConfigKey("fudp_client").InstallFountainInstances()var InstallFountainInstances = Lib.InstallFountainInstancesTruy cập thẳng tới bộ quản lý thư viện
var Lib = lib_3rd.NewLib(newClient, lib_3rd.WithDefaultConfigFunc[Config, Client](DefaultConfig))var WithConfigKey = Lib.WithConfigKeyfunc FindUDPHandler
func FindUDPHandler(msg proto.Message) fudp.HandleFindUDPHandler func;
func NewMessageByName
func NewMessageByName(mName string) (proto.Message, error)NewMessageByName func
func RegisterServiceHandler
func RegisterServiceHandler(x proto.Message, handler fudp.Handle)func WithAddr
func WithAddr(addr string) lib_3rd.Option[Config]func WithClientCallbackInstance
func WithClientCallbackInstance(instance ClientCallBack) lib_3rd.Option[Config]func WithConfig
func WithConfig(conf *Config) lib_3rd.Option[Config]WithConfig
func WithDisableTraceInterceptor
func WithDisableTraceInterceptor(disable ...bool) lib_3rd.Option[Config]func WithHostName
func WithHostName(hostname string) lib_3rd.Option[Config]func WithMaxReconnectCallback
func WithMaxReconnectCallback(cb func()) lib_3rd.Option[Config]func WithProtoName
func WithProtoName(protoName string) lib_3rd.Option[Config]func WithSendChanSize
func WithSendChanSize(sendChanSize int) lib_3rd.Option[Config]type Client
Client type
type Client struct {
// contains filtered or unexported fields
}func (*Client) AutoReconnect
func (c *Client) AutoReconnect() boolAutoReconnect func
func (*Client) Destroy
func (c *Client) Destroy()Destroy func
func (*Client) GetConn
func (c *Client) GetConn() *connect.Connectionfunc (*Client) GetConnection
func (c *Client) GetConnection() *connect.ConnectionGetConnection func
func (*Client) GetRemoteAddress
func (c *Client) GetRemoteAddress() stringGetRemoteAddress func
func (*Client) GetRemoteName
func (c *Client) GetRemoteName() stringGetRemoteName func
func (*Client) GetRemoteTypeName
func (c *Client) GetRemoteTypeName() (name, typeS string)GetRemoteTypeName func
func (*Client) GetTimer
func (c *Client) GetTimer() time.DurationGetTimer func
func (*Client) OnUDPConnectionClosed
func (c *Client) OnUDPConnectionClosed(*connect.Connection)func (*Client) PingLoop
func (c *Client) PingLoop()GetConnection func
func (*Client) Reconnect
func (c *Client) Reconnect()Reconnect func
func (*Client) Send
func (c *Client) Send(msg any) errorSend func
func (*Client) SendWithContext
func (c *Client) SendWithContext(ctx context.Context, msg any) errorSendWithOperatorContext sends message with tracing context
func (*Client) SendWithOperatorContext
func (c *Client) SendWithOperatorContext(ctx context.Context, msg any, operation string) errorSendWithOperatorContext sends message with operation name and tracing context
func (*Client) Serving
func (c *Client) Serving() errorServing func
func (*Client) SetLocalName
func (c *Client) SetLocalName(name string)func (*Client) SetTimer
func (c *Client) SetTimer(d time.Duration)SetTimer func
func (*Client) StartTimer
func (c *Client) StartTimer()StartTimer func
type ClientCallBack
ClientCallBack interface
type ClientCallBack interface {
OnUDPClientDataArrived(c *Client, msg any) error
OnUDPClientTimer(c *Client)
OnUDPConnectionClosed(conn *connect.Connection)
}type Config
Config type
type Config struct {
lib_3rd.BaseConfig `conf:",squash"`
Addr string `conf:"addr" json:"addr,omitempty"`
ServerName string `conf:"server_name" json:"server_name,omitempty"`
ProtoName string `conf:"proto_name" json:"proto_name,omitempty"`
MessageChanSize int `conf:"message_chan_size" json:"message_chan_size,omitempty"`
DisableTraceInterceptor bool `conf:"disable_trace_interceptor" json:"disable_trace_interceptor,omitempty"`
WriteTimeout time.Duration `conf:"write_timeout" json:"write_timeout,omitempty"` // in milliseconds
// contains filtered or unexported fields
}func DefaultConfig
func DefaultConfig() *Configfunc (*Config) Validate
func (conf *Config) Validate() errortype UDPInterceptor
type UDPInterceptor func(ctx context.Context, operation string, data []byte, addr string) (context.Context, func(result []byte, err error))Generated by gomarkdoc