Documentation
¶
Index ¶
- func Cli()
- func ConfigureForEnv(env string, cb func(cfg *config.Configuration) *config.Configuration)
- func EnsureRegistered(pluginName string)
- func GetEnv() string
- func GetGameName() string
- func Initialize(gameName string, env string)
- func Publish(e interface{}) error
- func RedisDel(key string) *redis2.IntCmd
- func RedisExists(key string) *redis2.IntCmd
- func RedisFlushAll() error
- func RedisGet(key string) *redis2.StringCmd
- func RedisHExists(key string, mapKey string) *redis2.BoolCmd
- func RedisHGet(key string, mapKey string) *redis2.StringCmd
- func RedisHGetAll(key string) *redis2.MapStringStringCmd
- func RedisHMSet(key string, values map[string]interface{}) *redis2.BoolCmd
- func RedisHSet(key string, mapKey string, value interface{}) *redis2.IntCmd
- func RedisKeys(pattern string) *redis2.StringSliceCmd
- func RedisPSubscribe(channels ...string) *redis2.PubSub
- func RedisPing() error
- func RedisSAdd(key string, value interface{}) *redis2.IntCmd
- func RedisSIsMember(key string, value interface{}) *redis2.BoolCmd
- func RedisSMembers(key string) *redis2.StringSliceCmd
- func RedisSRem(key string, value interface{}) *redis2.IntCmd
- func RedisSet(key string, value interface{}) *redis2.StatusCmd
- func RedisSubscribe(channels ...string) *redis2.PubSub
- func RegisterAfterServiceStartCallback(service string, callback func())
- func RegisterAfterStartCallback(callback func())
- func RegisterAfterStartCallbackForEnv(env string, callback func())
- func RegisterAfterStopCallback(callback func())
- func RegisterAfterStopCallbackForEnv(env string, callback func())
- func RegisterBeforeServiceStartCallback(service string, callback func())
- func RegisterBeforeServiceStartCallbackForEnv(service string, env string, callback func())
- func RegisterBeforeServiceStopCallback(service string, callback func())
- func RegisterBeforeServiceStopCallbackForEnv(service string, env string, callback func())
- func RegisterBeforeStartCallback(callback func())
- func RegisterBeforeStartCallbackForEnv(env string, callback func())
- func RegisterBeforeStopCallback(callback func())
- func RegisterBeforeStopCallbackForEnv(env string, callback func())
- func RegisterPlugin(plugin plugin.Plugin)
- func Running() chan bool
- func SetEnv(env string)
- func Start()
- func Stop()
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureForEnv ¶ added in v0.2.0
func ConfigureForEnv(env string, cb func(cfg *config.Configuration) *config.Configuration)
ConfigureForEnv configures the engine for the provided environment.
func EnsureRegistered ¶ added in v0.2.0
func EnsureRegistered(pluginName string)
EnsureRegistered ensures that the plugin is registered with the engine. If the plugin is not registered, and the engine will panic. This should be used by plugins that need to ensure that another plugin is registered before they can start.
func GetGameName ¶ added in v0.2.0
func GetGameName() string
GetGameName returns the name of the game.
func Initialize ¶ added in v0.2.0
Initialize is the first function called when the engine is started. It initializes the engine, and should be called before any other engine functions.
func Publish ¶ added in v0.2.0
func Publish(e interface{}) error
Publish publishes an event on the message bus. It accepts an event and an arbitrary number of arguments that will be passed to the event's topic and payload constructors.
func RedisExists ¶ added in v0.2.0
RedisExists returns if the provided key exists in the Redis database.
func RedisFlushAll ¶ added in v0.2.0
func RedisFlushAll() error
RedisFlushAll flushes all Redis databases.
func RedisGet ¶ added in v0.2.0
RedisGet returns the value for the provided key from the Redis database.
func RedisHExists ¶ added in v0.2.0
RedisHExists returns true if the provided map key exists in the provided map key.
func RedisHGet ¶ added in v0.2.0
RedisHGet returns the value for the provided map key and map key from the Redis database.
func RedisHGetAll ¶ added in v0.2.0
func RedisHGetAll(key string) *redis2.MapStringStringCmd
RedisHGetAll returns the values for the provided map key from the Redis database.
func RedisHMSet ¶ added in v0.2.0
RedisHMSet sets the values for the provided map key from the Redis database.
func RedisHSet ¶ added in v0.2.0
RedisHSet sets the value for the provided map key and map key in the Redis database.
func RedisKeys ¶ added in v0.2.0
func RedisKeys(pattern string) *redis2.StringSliceCmd
RedisKeys returns the keys for the provided pattern from the Redis database.
func RedisPSubscribe ¶ added in v0.2.0
RedisPSubscribe pattern subscribes to a channel on Redis. This should not be confused with PSubscribe, which subscribes to an event, even though it uses the underlying Redis PubSub command.
func RedisPing ¶ added in v0.2.0
func RedisPing() error
RedisPing pings the Redis server. This is a direct pass-through to the Redis client, simply setting the context.
func RedisSAdd ¶ added in v0.2.0
RedisSAdd adds the provided members to the set for the provided key.
func RedisSIsMember ¶ added in v0.2.0
RedisSIsMember returns true if the provided member is a member of the set for the provided key.
func RedisSMembers ¶ added in v0.2.0
func RedisSMembers(key string) *redis2.StringSliceCmd
RedisSMembers returns the members of the set for the provided key.
func RedisSRem ¶ added in v0.2.0
RedisSRem removes the provided members from the set for the provided key.
func RedisSubscribe ¶ added in v0.2.0
RedisSubscribe subscribes to a channel on Redis. This should not be confused with PSubscribe, which subscribes to an // event, even though it uses the underlying Redis PubSub command.
func RegisterAfterServiceStartCallback ¶ added in v0.2.0
func RegisterAfterServiceStartCallback(service string, callback func())
RegisterAfterServiceStartCallback registers a callback function that is called after the service is started.
func RegisterAfterStartCallback ¶ added in v0.2.0
func RegisterAfterStartCallback(callback func())
RegisterAfterStartCallback registers a callback function that is called after the engine is started.
func RegisterAfterStartCallbackForEnv ¶ added in v0.2.0
func RegisterAfterStartCallbackForEnv(env string, callback func())
RegisterAfterStartCallbackForEnv registers a callback function that is called after the engine is started, but only if the engine is running in the provided environment.
func RegisterAfterStopCallback ¶ added in v0.2.0
func RegisterAfterStopCallback(callback func())
RegisterAfterStopCallback registers a callback function that is called after the engine is stopped.
func RegisterAfterStopCallbackForEnv ¶ added in v0.2.0
func RegisterAfterStopCallbackForEnv(env string, callback func())
RegisterAfterStopCallbackForEnv registers a callback function that is called after the engine is stopped, but only if the engine is running in the provided environment.
func RegisterBeforeServiceStartCallback ¶ added in v0.2.0
func RegisterBeforeServiceStartCallback(service string, callback func())
RegisterBeforeServiceStartCallback registers a callback function that is called when the engine is started.
func RegisterBeforeServiceStartCallbackForEnv ¶ added in v0.2.0
RegisterBeforeServiceStartCallbackForEnv registers a callback function that is called when the engine is started, but only if the provided environment matches the current environment.
func RegisterBeforeServiceStopCallback ¶ added in v0.2.0
func RegisterBeforeServiceStopCallback(service string, callback func())
RegisterBeforeServiceStopCallback registers a callback function that is called when the engine is stopped.
func RegisterBeforeServiceStopCallbackForEnv ¶ added in v0.2.0
RegisterBeforeServiceStopCallbackForEnv registers a callback function that is called when the engine is stopped, but only if the provided environment matches the current environment.
func RegisterBeforeStartCallback ¶ added in v0.2.0
func RegisterBeforeStartCallback(callback func())
RegisterBeforeStartCallback registers a callback function that is called before the engine is started.
func RegisterBeforeStartCallbackForEnv ¶ added in v0.2.0
func RegisterBeforeStartCallbackForEnv(env string, callback func())
RegisterBeforeStartCallbackForEnv registers a callback function that is called before the engine is started, but only if the provided environment matches the current environment.
func RegisterBeforeStopCallback ¶ added in v0.2.0
func RegisterBeforeStopCallback(callback func())
RegisterBeforeStopCallback registers a callback function that is called before the engine is stopped.
func RegisterBeforeStopCallbackForEnv ¶ added in v0.2.0
func RegisterBeforeStopCallbackForEnv(env string, callback func())
RegisterBeforeStopCallbackForEnv registers a callback function that is called before the engine is stopped, but only if the provided environment matches the current environment.
func RegisterPlugin ¶
RegisterPlugin registers a plugin with the engine. Plugins need to be registered before the engine is started, but after the engine is initialized. Plugins should conform to the plugin interface.
func Running ¶ added in v0.2.0
func Running() chan bool
Running returns a channel that is closed when the engine is stopped.
func SetEnv ¶ added in v0.2.0
func SetEnv(env string)
SetEnv sets the environment for the engine. The environment defaults to "dev".
Types ¶
type Subscription ¶ added in v0.2.0
type Subscription interface {
Stop()
}
Subscription represents a pubsub to an event.
func PSubscribe ¶ added in v0.2.0
func PSubscribe(e event.Event, cb func(payload event.EventPayload)) Subscription
PSubscribe subscribes to an event on the message bus. It accepts an event and a callback function that will be called when the event is published. The callback function will be passed an EventPayload, with which `Unmarshal` can be called to unmarshal the payload into a Go struct. PSubscribe uses [Redis PubSub PSubscribe](https://redis.io/commands/psubscribe). It should not be confused with the `RedisPSubscribe` function, which simply subscribes to a channel on Redis, without wiring any of the underlying event handling.
func Subscribe ¶ added in v0.2.0
func Subscribe(e event.Event, cb func(event.EventPayload)) Subscription
Subscribe subscribes to an event on the message bus. It accepts an event and a callback function that will be called when the event is published. The callback function will be passed an EventPayload, with which `Unmarshal` can be called to unmarshal the payload into a Go struct. PSubscribe uses [Redis PubSub PSubscribe](https://redis.io/commands/subscribe). It should not be confused with the `RedisSubscribe` function, which simply subscribes to a channel on Redis, without wiring any of the underlying event handling.