api

package module
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 14 Imported by: 1

README

FOSSA Status

iguagile-room-api

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRoomRequest

type CreateRoomRequest struct {
	ApplicationName string            `json:"application_name"`
	Version         string            `json:"version"`
	Password        string            `json:"password"`
	MaxUser         int               `json:"max_user"`
	Information     map[string]string `json:"information"`
}

CreateRoomRequest is api request.

type Room

type Room struct {
	RoomID          int               `json:"room_id"`
	RequirePassword bool              `json:"require_password"`
	MaxUser         int               `json:"max_user"`
	ConnectedUser   int               `json:"connected_user"`
	Server          Server            `json:"server"`
	Token           string            `json:"token"`
	Information     map[string]string `json:"information"`
	ApplicationName string            `json:"-"`
	Version         string            `json:"-"`
	// contains filtered or unexported fields
}

Room is room information.

type RoomAPIResponse

type RoomAPIResponse struct {
	Success bool        `json:"success"`
	Result  interface{} `json:"result"`
	Error   string      `json:"error"`
}

RoomAPIResponse is api response.

type RoomAPIServer

type RoomAPIServer struct {
	// Address is room api server address.
	Address string

	// BaseUri is base uri of room api.
	BaseUri string

	// RedisHost is redis address.
	RedisHost string

	// MaxUser is max value of room capacity.
	MaxUser int

	ServerDeadLine time.Duration
	RoomDeadLine   time.Duration
	Logger         *log.Logger
	// contains filtered or unexported fields
}

RoomAPIServer is room api server.

func NewRoomAPIServer

func NewRoomAPIServer() *RoomAPIServer

NewRoomAPIServer is an instance of RoomAPIServer.

func (*RoomAPIServer) Start

func (s *RoomAPIServer) Start() error

Start starts an room api server.

type RoomManager

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

RoomManager is room manager.

func (*RoomManager) Delete

func (m *RoomManager) Delete(roomID int)

Delete deletes the room.

func (*RoomManager) DeleteDeadRoomAtPeriodic

func (m *RoomManager) DeleteDeadRoomAtPeriodic(ctx context.Context, duration time.Duration)

DeleteDeadRoomAtPeriodic removes dead rooms at regular intervals

func (*RoomManager) FindRoom

func (m *RoomManager) FindRoom(roomID int) (room *Room)

FindRoom returns the room.

func (*RoomManager) Search

func (m *RoomManager) Search(name, version string) (rooms []*Room)

Search returns returns all rooms with matching application name and version.

func (*RoomManager) Store

func (m *RoomManager) Store(room *Room)

Store stores the room.

type Server

type Server struct {
	Host     string `json:"server"`
	Port     int    `json:"port"`
	ServerID int    `json:"-"`
	Load     int    `json:"-"`
	APIPort  int    `json:"-"`
	Token    []byte `json:"-"`
	// contains filtered or unexported fields
}

Server is room server information.

type ServerManager

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

ServerManager is room server manager.

func (*ServerManager) Delete

func (m *ServerManager) Delete(serverID int)

Delete deletes the server.

func (*ServerManager) DeleteUnhealthServerAtPeriodic

func (m *ServerManager) DeleteUnhealthServerAtPeriodic(ctx context.Context, duration time.Duration)

DeleteUnhealthServerAtPeriodic removes dead servers at regular intervals

func (*ServerManager) LoadServer

func (m *ServerManager) LoadServer(serverID int) (server *Server)

LoadServer returns the server.

func (*ServerManager) LoadServers

func (m *ServerManager) LoadServers() (servers []*Server)

LoadServers returns all servers.

func (*ServerManager) PickupLowLoadServer

func (m *ServerManager) PickupLowLoadServer() (server *Server)

PickupLowLoadServer returns the server with the lowest load.

func (*ServerManager) Store

func (m *ServerManager) Store(server *Server)

Store stores the server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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