engine

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 9 Imported by: 7

README

Overview

Mjolnir is a MUD engine written in Go, with a goal of providing a flexible and extensible framework for writing MUDs. This repository contains the core engine and plugins. For a quick start, see the Mjolnir MUD Engine Template.

Documentation

The engine documentation can be found within the Wiki for this repository.

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
  2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
  3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer.
  4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

Code of Conduct

Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

Our Standards

Examples of behavior that contributes to creating a positive environment include:

  • Using welcoming and inclusive language
  • Being respectful of differing viewpoints and experiences
  • Gracefully accepting constructive criticism
  • Focusing on what is best for the community
  • Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

  • The use of sexualized language or imagery and unwelcome sexual attention or advances
  • Trolling, insulting/derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or electronic address, without explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cli added in v0.2.0

func Cli()

Cli returns and execute CLI commands.

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 GetEnv added in v0.2.0

func GetEnv() string

GetEnv returns the environment for the engine.

func GetGameName added in v0.2.0

func GetGameName() string

GetGameName returns the name of the game.

func Initialize added in v0.2.0

func Initialize(gameName string, env string)

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 RedisDel added in v0.2.0

func RedisDel(key string) *redis2.IntCmd

RedisDel deletes the provided key from the Redis database.

func RedisExists added in v0.2.0

func RedisExists(key string) *redis2.IntCmd

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

func RedisGet(key string) *redis2.StringCmd

RedisGet returns the value for the provided key from the Redis database.

func RedisHExists added in v0.2.0

func RedisHExists(key string, mapKey string) *redis2.BoolCmd

RedisHExists returns true if the provided map key exists in the provided map key.

func RedisHGet added in v0.2.0

func RedisHGet(key string, mapKey string) *redis2.StringCmd

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

func RedisHMSet(key string, values map[string]interface{}) *redis2.BoolCmd

RedisHMSet sets the values for the provided map key from the Redis database.

func RedisHSet added in v0.2.0

func RedisHSet(key string, mapKey string, value interface{}) *redis2.IntCmd

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

func RedisPSubscribe(channels ...string) *redis2.PubSub

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

func RedisSAdd(key string, value interface{}) *redis2.IntCmd

RedisSAdd adds the provided members to the set for the provided key.

func RedisSIsMember added in v0.2.0

func RedisSIsMember(key string, value interface{}) *redis2.BoolCmd

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

func RedisSRem(key string, value interface{}) *redis2.IntCmd

RedisSRem removes the provided members from the set for the provided key.

func RedisSet added in v0.2.0

func RedisSet(key string, value interface{}) *redis2.StatusCmd

RedisSet sets the value for the provided key in the Redis database.

func RedisSubscribe added in v0.2.0

func RedisSubscribe(channels ...string) *redis2.PubSub

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

func RegisterBeforeServiceStartCallbackForEnv(service string, env string, callback func())

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

func RegisterBeforeServiceStopCallbackForEnv(service string, env string, callback func())

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

func RegisterPlugin(plugin plugin.Plugin)

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".

func Start

func Start()

Start starts the engine. It should be called after the engine is initialized, and after all plugins are registered.

func Stop

func Stop()

Stop stops the engine.

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.

Directories

Path Synopsis
internal
cli
pkg
plugins
ecs

Jump to

Keyboard shortcuts

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