Documentation ¶
Index ¶
- Variables
- func ExtendEcho(e *echo.Echo, opts ...Option)
- func Listen(addr string, opts ...Option)
- func Shutdown()
- func WatchShutdown()
- type Group
- func (g *Group) Add(session *session.Session) error
- func (g *Group) Broadcast(route string, v interface{}) error
- func (g *Group) Close() error
- func (g *Group) Contains(uid int64) bool
- func (g *Group) ContainsUUID(uuid string) bool
- func (g *Group) Count() int
- func (g *Group) GetMember(uid int64) (*session.Session, error)
- func (g *Group) GetName() string
- func (g *Group) GetOnUpdate() *scheduler.GameLoop
- func (g *Group) InitDriver(driverType azdrivers.DriverKeyType, driverString string, isNew bool) error
- func (g *Group) Leave(s *session.Session) error
- func (g *Group) LeaveAll() error
- func (g *Group) Member(uid int64) (*session.Session, error)
- func (g *Group) MemberUUID(uuid string) (*session.Session, error)
- func (g *Group) Members() []int64
- func (g *Group) MembersShortUUID() []string
- func (g *Group) MembersUUID() []string
- func (g *Group) Multicast(route string, v interface{}, filter SessionFilter) error
- func (g *Group) SetOnUpdate(fn func(delta float64), tickRate int64)
- type LifeCycles
- type Option
- func WithAdvertiseAddr(addr string, retryInterval ...time.Duration) Option
- func WithCheckOriginFunc(fn func(*http.Request) bool) Option
- func WithClientAddr(addr string) Option
- func WithComponents(components *component.Components) Option
- func WithDebugMode() Option
- func WithDictionary(dict map[string]uint16) Option
- func WithFirebase(path string) Option
- func WithGrpcOptions(opts ...grpc.DialOption) Option
- func WithHandshakeValidator(fn func([]byte) error) Option
- func WithHeartbeatInterval(d time.Duration) Option
- func WithIsWebsocket(enableWs bool) Option
- func WithJWT(authJWT *auth.JWT) Option
- func WithJWTOpts(signKey, algo string, genTokenFunc auth.JWTFunc) Option
- func WithLabel(label string) Option
- func WithLogger(l log.Logger) Option
- func WithMaster() Option
- func WithMongo(uri string) Option
- func WithPipeline(pipeline pipeline.Pipeline) Option
- func WithSerializer(serializer serialize.Serializer) Option
- func WithTSLConfig(certificate, key string) Option
- func WithTimerPrecision(precision time.Duration) Option
- func WithWSPath(path string) Option
- type SessionFilter
Constants ¶
This section is empty.
Variables ¶
var ( ErrCloseClosedGroup = errors.New("close closed group") ErrClosedGroup = errors.New("group closed") ErrMemberNotFound = errors.New("member not found in the group") ErrSessionDuplication = errors.New("session has existed in the current group") )
Errors that could be occurred during message handling.
var VERSION = "0.6.0"
VERSION returns current amoeba version
Functions ¶
func ExtendEcho ¶
func ExtendEcho(e *echo.Echo, opts ...Option)
ExtendEcho -- HELPER TO EXTEND AN ECHO WEB SERVER
func Listen ¶
Listen listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections.
func WatchShutdown ¶
func WatchShutdown()
Types ¶
type Group ¶
Group represents a session group which used to manage a number of sessions, data send to the group will send to all session in it.
func NewGroupWithDriver ¶
func NewGroupWithDriver(n string, driverType azdrivers.DriverKeyType, newDriver bool, onUpdate func()) (*Group, error)
NewGroupWithDriver -- returns a new group instance with driver support driverType = mongo | firebase driverString = mongo uri | firebase cfg file path
func (*Group) ContainsUUID ¶
Contains check whether a UUID is contained in current group or not
func (*Group) GetOnUpdate ¶
func (*Group) InitDriver ¶
func (*Group) MemberUUID ¶
Member returns specified UUID's session
func (*Group) Multicast ¶
func (g *Group) Multicast(route string, v interface{}, filter SessionFilter) error
Multicast push the message to the filtered clients
func (*Group) SetOnUpdate ¶
type LifeCycles ¶
type Option ¶
func WithAdvertiseAddr ¶
WithAdvertiseAddr sets the advertise address option, it will be the listen address in master node and an advertise address which cluster member to connect
func WithCheckOriginFunc ¶
WithCheckOriginFunc sets the function that check `Origin` in http headers
func WithClientAddr ¶
WithMemberAddr sets the listen address which is used to establish connection between cluster members. Will select an available port automatically if no member address setting and panic if no available port
func WithComponents ¶
func WithComponents(components *component.Components) Option
WithComponents sets the Components
func WithDebugMode ¶
func WithDebugMode() Option
WithDebugMode let 'amoeba' to run under Debug mode.
func WithDictionary ¶
SetDictionary sets routes map
func WithFirebase ¶
func WithGrpcOptions ¶
func WithGrpcOptions(opts ...grpc.DialOption) Option
WithGrpcOptions sets the grpc dial options
func WithHandshakeValidator ¶
WithHandshakeValidator sets the function that Verify `handshake` data
func WithHeartbeatInterval ¶
WithHeartbeatInterval sets Heartbeat time interval
func WithIsWebsocket ¶
WithIsWebsocket indicates whether current node WebSocket is enabled
func WithMaster ¶
func WithMaster() Option
WithMaster sets the option to indicate whether the current node is master node
func WithPipeline ¶
func WithSerializer ¶
func WithSerializer(serializer serialize.Serializer) Option
WithSerializer customizes application serializer, which automatically Marshal and UnMarshal handler payload
func WithTSLConfig ¶
WithTSLConfig sets the `key` and `certificate` of TSL
func WithTimerPrecision ¶
SetTimerPrecision sets the ticker precision, and time precision can not less than a Millisecond, and can not change after application running. The default precision is time.Second
func WithWSPath ¶
type SessionFilter ¶
SessionFilter represents a filter which was used to filter session when Multicast, the session will receive the message while filter returns true.
Directories ¶
Path | Synopsis |
---|---|
benchmark
|
|
examples
|
|
demo/amoeba
https://github.com/revzim/amoeba/examples/chat
|
https://github.com/revzim/amoeba/examples/chat |
demo/chat2
https://github.com/revzim/amoeba/examples/chat2
|
https://github.com/revzim/amoeba/examples/chat2 |
internal
|
|
env
env represents the environment of the current process, includes work path and config path etc.
|
env represents the environment of the current process, includes work path and config path etc. |