util

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 22 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DefaultStatCycle   = time.Second * 3
	DefaultGRPCTimeout = 15 * time.Second
)

Variables

This section is empty.

Functions

func BoolToString added in v1.10.0

func BoolToString(flag bool) string

func GetArgs added in v1.10.0

func GetArgs(args ...string) (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 string)

func GetRedisPeerKey added in v1.10.0

func GetRedisPeerKey(sid, uid string) string

func GetRedisPeersPrefixKey added in v1.10.0

func GetRedisPeersPrefixKey(sid string) string

func GetRedisRoomKey added in v1.10.0

func GetRedisRoomKey(sid string) string

func GetServiceInfo added in v1.9.1

func GetServiceInfo(nc nrpc.NatsConn, nid string, selfnid string) (map[string][]*reflection.MethodDescriptor, error)

Get service information through reflection, this feature can be used to create json-rpc, restful API

func NewNatsConn added in v1.9.0

func NewNatsConn(url string) (*nats.Conn, error)

NewNatsConn .

func RandomString added in v1.5.0

func RandomString(n int) string

RandomString generate a random string

func Recover

func Recover(flag string)

Recover print stack

func StringToBool added in v1.10.0

func StringToBool(flag string) bool

Types

type AtomicBool added in v1.5.0

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

AtomicBool represents a atomic bool

func (*AtomicBool) Get added in v1.5.0

func (b *AtomicBool) Get() bool

Get atomic bool

func (*AtomicBool) Set added in v1.5.0

func (b *AtomicBool) Set(value bool) (swapped bool)

Set atomic bool

type ClientConnInterface added in v1.9.0

type ClientConnInterface interface {
	grpc.ClientConnInterface
	Close() error
}

ClientConnInterface .

func NewGRPCClientConnForNode added in v1.9.0

func NewGRPCClientConnForNode(node discovery.Node) (ClientConnInterface, error)

NewGRPCClientForNode .

type ServiceInterface added in v1.9.0

type ServiceInterface interface {
	grpc.ServiceRegistrar
	Serve(lis net.Listener) error
	Stop()
}

ServiceInterface .

func NewGRPCServiceForNode added in v1.9.0

func NewGRPCServiceForNode(node discovery.Node) (ServiceInterface, error)

NewGRPCServiceForNode .

type WrapperedGRPCWebServer added in v1.10.0

type WrapperedGRPCWebServer struct {
	GRPCServer *grpc.Server
	// contains filtered or unexported fields
}

func NewWrapperedGRPCWebServer added in v1.10.0

func NewWrapperedGRPCWebServer(options WrapperedServerOptions, s *grpc.Server) *WrapperedGRPCWebServer

func (*WrapperedGRPCWebServer) Serve added in v1.10.0

func (s *WrapperedGRPCWebServer) Serve() error

type WrapperedServerOptions added in v1.10.0

type WrapperedServerOptions struct {
	Addr                  string
	Cert                  string
	Key                   string
	AllowAllOrigins       bool
	AllowedOrigins        *[]string
	AllowedHeaders        *[]string
	UseWebSocket          bool
	WebsocketPingInterval time.Duration
}

func DefaultWrapperedServerOptions added in v1.10.0

func DefaultWrapperedServerOptions() WrapperedServerOptions

func NewWrapperedServerOptions added in v1.10.0

func NewWrapperedServerOptions(addr, cert, key string, websocket bool) WrapperedServerOptions

Jump to

Keyboard shortcuts

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