sickhye / pitaya

An awesome game server framework written in go 😍

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attention

Pitaya is currently under development and is not yet ready for production use. We're working on tests and better documentation and we'll update the project as soon as possible.

pitaya Build Status Coverage Status GoDoc Go Report Card MIT licensed

Pitaya is an easy to use, fast and lightweight game server framework inspired by starx and pomelo and built on top of nano's networking library.

The goal of pitaya is to provide a basic development framework for distributed multiplayer games and server-side applications.

How to build a system with pitaya

What does a pitaya application look like?

A pitaya application is a collection of components made of handlers and/or remotes. Handlers are methods that will be called directly by the client while remotes are called by other servers via RPCs. Once you register a component to pitaya, pitaya will register to its service container all methods that can be converted to Handler or Remote. Pitaya service handler will be called when the client makes a request and it receives two parameters while handling a message:

  • *session.Session: corresponding a client that apply this request or notify.
  • pointer or []byte: the payload of the request.

When the server has processed the logic, it must return a struct that will be serialized and sent to the client.

Standalone application

The easiest way of running pitaya is by starting a standalone application. There's an working example here.

Cluster mode

In order to run several pitaya applications in a cluster it is necessary to configure RPC and Service Discovery services. Currently we are using NATS for RPC and ETCD for service discovery. Other options may be implemented in the future.

There's an working example of pitaya running in cluster mode here.

To run this example you need to have both nats and etcd running. To start them you can use the following commands:

docker run -p 4222:4222 -d --name nats-main nats
docker run -d -p 2379:2379 -p 2380:2380 appcelerator/etcd

You can start the backend and frontend servers with the following commands:

make run-cluster-example-frontend
make run-cluster-example-backend
Frontend and backend servers

In short, frontend servers handle client calls while backend servers only handle RPCs coming from other servers.

Resources

Installation

go get github.com/topfreegames/pitaya

# dependencies
dep ensure

Testing

TBD

Benchmark

TBD

License

MIT License

Forked from Β© 2017 nano Authors

About

An awesome game server framework written in go 😍

License:MIT License


Languages

Language:Go 99.4%Language:Makefile 0.5%Language:Batchfile 0.0%Language:Shell 0.0%