Skip to content

Import path: gitlab.soludian.com/soludian/fountain/clients/fudp_client

fudp_client

go
import "gitlab.soludian.com/soludian/fountain/clients/fudp_client"

Index

Constants

PackageName sets the package name

go
const KPackageName = "fudp_client"

Variables

go
var GetFountainInstance = Lib.GetFountainInstance

go
var GetFountainManager = Lib.GetFountainManager

Sử 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()
go
var InstallFountainInstance = Lib.InstallFountainInstance

Sử 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()
go
var InstallFountainInstances = Lib.InstallFountainInstances

Truy cập thẳng tới bộ quản lý thư viện

go
var Lib = lib_3rd.NewLib(newClient, lib_3rd.WithDefaultConfigFunc[Config, Client](DefaultConfig))

go
var WithConfigKey = Lib.WithConfigKey

func FindUDPHandler

go
func FindUDPHandler(msg proto.Message) fudp.Handle

FindUDPHandler func;

func NewMessageByName

go
func NewMessageByName(mName string) (proto.Message, error)

NewMessageByName func

func RegisterServiceHandler

go
func RegisterServiceHandler(x proto.Message, handler fudp.Handle)

func WithAddr

go
func WithAddr(addr string) lib_3rd.Option[Config]

func WithClientCallbackInstance

go
func WithClientCallbackInstance(instance ClientCallBack) lib_3rd.Option[Config]

func WithConfig

go
func WithConfig(conf *Config) lib_3rd.Option[Config]

WithConfig

func WithDisableTraceInterceptor

go
func WithDisableTraceInterceptor(disable ...bool) lib_3rd.Option[Config]

func WithHostName

go
func WithHostName(hostname string) lib_3rd.Option[Config]

func WithMaxReconnectCallback

go
func WithMaxReconnectCallback(cb func()) lib_3rd.Option[Config]

func WithProtoName

go
func WithProtoName(protoName string) lib_3rd.Option[Config]

func WithSendChanSize

go
func WithSendChanSize(sendChanSize int) lib_3rd.Option[Config]

type Client

Client type

go
type Client struct {
    // contains filtered or unexported fields
}

func (*Client) AutoReconnect

go
func (c *Client) AutoReconnect() bool

AutoReconnect func

func (*Client) Destroy

go
func (c *Client) Destroy()

Destroy func

func (*Client) GetConn

go
func (c *Client) GetConn() *connect.Connection

func (*Client) GetConnection

go
func (c *Client) GetConnection() *connect.Connection

GetConnection func

func (*Client) GetRemoteAddress

go
func (c *Client) GetRemoteAddress() string

GetRemoteAddress func

func (*Client) GetRemoteName

go
func (c *Client) GetRemoteName() string

GetRemoteName func

func (*Client) GetRemoteTypeName

go
func (c *Client) GetRemoteTypeName() (name, typeS string)

GetRemoteTypeName func

func (*Client) GetTimer

go
func (c *Client) GetTimer() time.Duration

GetTimer func

func (*Client) OnUDPConnectionClosed

go
func (c *Client) OnUDPConnectionClosed(*connect.Connection)

func (*Client) PingLoop

go
func (c *Client) PingLoop()

GetConnection func

func (*Client) Reconnect

go
func (c *Client) Reconnect()

Reconnect func

func (*Client) Send

go
func (c *Client) Send(msg any) error

Send func

func (*Client) SendWithContext

go
func (c *Client) SendWithContext(ctx context.Context, msg any) error

SendWithOperatorContext sends message with tracing context

func (*Client) SendWithOperatorContext

go
func (c *Client) SendWithOperatorContext(ctx context.Context, msg any, operation string) error

SendWithOperatorContext sends message with operation name and tracing context

func (*Client) Serving

go
func (c *Client) Serving() error

Serving func

func (*Client) SetLocalName

go
func (c *Client) SetLocalName(name string)

func (*Client) SetTimer

go
func (c *Client) SetTimer(d time.Duration)

SetTimer func

func (*Client) StartTimer

go
func (c *Client) StartTimer()

StartTimer func

type ClientCallBack

ClientCallBack interface

go
type ClientCallBack interface {
    OnUDPClientDataArrived(c *Client, msg any) error
    OnUDPClientTimer(c *Client)
    OnUDPConnectionClosed(conn *connect.Connection)
}

type Config

Config type

go
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

go
func DefaultConfig() *Config

func (*Config) Validate

go
func (conf *Config) Validate() error

type UDPInterceptor

go
type UDPInterceptor func(ctx context.Context, operation string, data []byte, addr string) (context.Context, func(result []byte, err error))

Generated by gomarkdoc