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 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.
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.
The easiest way of running pitaya
is by starting a standalone application. There's an working example here.
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
In short, frontend servers handle client calls while backend servers only handle RPCs coming from other servers.
-
Documents
-
Demo
- Implement a chat room in ~100 lines with pitaya and WebSocket (adapted from nano's example)
- Tadpole demo (adapted from nano's example)
- Pitaya cluster mode example
- Pitaya cluster mode with protobuf compression example
go get github.com/topfreegames/pitaya
# dependencies
dep ensure
TBD
TBD
Forked from © 2017 nano Authors