broker

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ConnectCodeLength = 8
View Source
const JobNamespace = "automuteus:jobs:"
View Source
const JobTTLSeconds = 3600

Variables

This section is empty.

Functions

func Ack

func Ack(ctx context.Context, redis *redis.Client, connCode string)

func AckSubscribe

func AckSubscribe(ctx context.Context, redis *redis.Client, connCode string) *redis.PubSub

func GetActiveGames

func GetActiveGames(client *redis.Client, secs int64) int64

func GetGuildCounter

func GetGuildCounter(client *redis.Client) int64

func GetVersionAndCommit

func GetVersionAndCommit(client *redis.Client) (string, string)

func PushJob

func PushJob(ctx context.Context, redis *redis.Client, connCode string, jobType JobType, payload string) error

func RemoveActiveGame

func RemoveActiveGame(client *redis.Client, connectCode string)

func Subscribe

func Subscribe(ctx context.Context, redis *redis.Client, connCode string) *redis.PubSub

Types

type Broker

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

func NewBroker

func NewBroker(redisAddr, redisUser, redisPass string) *Broker

func (*Broker) AckWorker

func (broker *Broker) AckWorker(ctx context.Context, connCode string, killChan <-chan bool)

anytime a bot "acks", then push a notification

func (*Broker) Start

func (broker *Broker) Start(port string)

func (*Broker) TaskCompletionListener

func (broker *Broker) TaskCompletionListener(taskID string, taskChan <-chan bool, killChan <-chan bool)

this function waits for a success message, OR, a closure of the channel from higher-up. But either way, we publish to Redis

func (*Broker) TasksListener

func (broker *Broker) TasksListener(server *socketio.Server, connectCode string, killchan <-chan bool)

type GameLobby

type GameLobby struct {
	LobbyCode string `json:"LobbyCode"`
	Region    int    `json:"Region"`
}

type Job

type Job struct {
	JobType JobType     `json:"type"`
	Payload interface{} `json:"payload"`
}

func PopJob

func PopJob(ctx context.Context, redis *redis.Client, connCode string) (Job, error)

type JobType

type JobType int
const (
	Connection JobType = iota
	Lobby
	State
	Player
	GameOver
)

type Resp

type Resp struct {
	Result string `json:"result"`
}

Jump to

Keyboard shortcuts

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