Import path:
gitlab.soludian.com/soludian/fountain/libs/fnet/fudp
fudp
import "gitlab.soludian.com/soludian/fountain/libs/fnet/fudp"Index
- Constants
- Variables
- func RegisterServiceHandler(x proto.Message, handler Handle)
- func WithAddr(addr string) lib_3rd.Option[config]
- func WithConfig(conf *config) lib_3rd.Option[config]
- func WithConnectionMaxIdleTime(duration time.Duration) lib_3rd.Option[config]
- func WithMaxConcurrentConnection(maxConcurrentConnection int) lib_3rd.Option[config]
- func WithName(name string) lib_3rd.Option[config]
- func WithProtoName(protoName string) lib_3rd.Option[config]
- func WithSendChanSize(sendChanSize int) lib_3rd.Option[config]
- func WithServerCallbackInstance(instance ServerCallback) lib_3rd.Option[config]
- func WithVacuumInterval(interval time.Duration) lib_3rd.Option[config]
- type Handle
- type Server
- func (s *Server) Destroy() error
- func (s *Server) GetConnection(addr *net.UDPAddr) *connect.Connection
- func (s *Server) GetConnectionCount() int
- func (s *Server) GracefulStop(ctx context.Context) error
- func (s *Server) IsRunning() bool
- func (s *Server) OnUDPConnectionClosed(conn *connect.Connection)
- func (s *Server) PackageName() string
- func (s *Server) Pause()
- func (s *Server) SendMessageBroadcast(msg any)
- func (s *Server) SendMessageByConn(conn *connect.Connection, msg any) error
- func (s *Server) SendMessageByConnAddr(addr *net.UDPAddr, msg any) error
- func (s *Server) SendMessageProtoByConn(conn *connect.Connection, cntl *codec.MessageController, msg proto.Message) error
- func (s *Server) Serving()
- type ServerCallback
Constants
const KMaxConcurrentConnection = 10000000const KPackageName = "ftcp_server"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:<value>
Usage:
config.yaml:
fudp:
name: default_name
...
code.go
fudp.InstallFountainInstance()
fudp.WithConfigKey("fudp").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:array<value>
Usage:
config.yaml:
fudp:
- name: default_name
...
code.go
fudp.InstallFountainInstances()
fudp.WithConfigKey("fudp").InstallFountainInstances()var InstallFountainInstances = Lib.InstallFountainInstancesvar KDefaultServerName = env.GetFullAppService(KPackageName)Truy cập thẳng tới bộ quản lý thư viện
var Lib = lib_3rd.NewLib(newServer, lib_3rd.WithDefaultConfigFunc[config, Server](DefaultConfig))var WithConfigKey = Lib.WithConfigKeyfunc RegisterServiceHandler
func RegisterServiceHandler(x proto.Message, handler Handle)RegisterServiceHandler func;
func WithAddr
func WithAddr(addr string) lib_3rd.Option[config]func WithConfig
func WithConfig(conf *config) lib_3rd.Option[config]func WithConnectionMaxIdleTime
func WithConnectionMaxIdleTime(duration time.Duration) lib_3rd.Option[config]func WithMaxConcurrentConnection
func WithMaxConcurrentConnection(maxConcurrentConnection int) lib_3rd.Option[config]func WithName
func WithName(name string) lib_3rd.Option[config]func WithProtoName
func WithProtoName(protoName string) lib_3rd.Option[config]func WithSendChanSize
func WithSendChanSize(sendChanSize int) lib_3rd.Option[config]func WithServerCallbackInstance
func WithServerCallbackInstance(instance ServerCallback) lib_3rd.Option[config]func WithVacuumInterval
func WithVacuumInterval(interval time.Duration) lib_3rd.Option[config]type Handle
type Handle func(*net.UDPAddr, *codec.MessageController, proto.Message) errorfunc FindHandler
func FindHandler(msg proto.Message) HandleFindHandler func;
type Server
type Server struct {
*runnable.ServerInstance
// contains filtered or unexported fields
}func (*Server) Destroy
func (s *Server) Destroy() errorDestroy func
func (*Server) GetConnection
func (s *Server) GetConnection(addr *net.UDPAddr) *connect.ConnectionGetConnection func
func (*Server) GetConnectionCount
func (s *Server) GetConnectionCount() intGetConnection func
func (*Server) GracefulStop
func (s *Server) GracefulStop(ctx context.Context) errorGracefulStop implements Runnable interface it will stop echo server gracefully
func (*Server) IsRunning
func (s *Server) IsRunning() boolIsRunning func
func (*Server) OnUDPConnectionClosed
func (s *Server) OnUDPConnectionClosed(conn *connect.Connection)OnUDPConnectionClosed func to implement connect.ConnectionClosedCallback interface
func (*Server) PackageName
func (s *Server) PackageName() stringPackageName package name
func (*Server) Pause
func (s *Server) Pause()Pause func
func (*Server) SendMessageBroadcast
func (s *Server) SendMessageBroadcast(msg any)SendMessageBroadcast func; Send msg to all connection that was connected; msg can be either *codec.Message or proto.Message or []byte
func (*Server) SendMessageByConn
func (s *Server) SendMessageByConn(conn *connect.Connection, msg any) errorSendMessageByConn func; Find client by addr and send msg to all connection that was connected
func (*Server) SendMessageByConnAddr
func (s *Server) SendMessageByConnAddr(addr *net.UDPAddr, msg any) errorSendMessageByConnID func; Send data according to addr
func (*Server) SendMessageProtoByConn
func (s *Server) SendMessageProtoByConn(conn *connect.Connection, cntl *codec.MessageController, msg proto.Message) errorSendMessageProtoByConn func; Find client by addr and send msg to all connection that was connected
func (*Server) Serving
func (s *Server) Serving()Serve func need run in a goroutine
type ServerCallback
type ServerCallback interface {
OnUDPDataArrived(addr *net.UDPAddr, msg any) error
OnUDPClientClosed(conn *connect.Connection)
}Generated by gomarkdoc