Scalable game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK.
Clone or download
Latest commit 97537f8 Oct 8, 2018
Permalink
Failed to load latest commit information.
acceptor save client's ip version on session (#63) Oct 5, 2018
agent save client's ip version on session (#63) Oct 5, 2018
benchmark update generated protos and proto example Jul 27, 2018
client Added support to TLS for client (#47) Aug 22, 2018
cluster Add hostname to server type (#62) Oct 3, 2018
component Feature/docs (#30) Jul 23, 2018
config reliable RPC (#61) Oct 5, 2018
constants reliable RPC (#61) Oct 5, 2018
context Remove all gob related code. Jun 4, 2018
defaultpipelines Fix validator when argument is nil (#52) Sep 5, 2018
deploy/kubernetes add example deploy with kubernetes Apr 23, 2018
docgenerator Add descriptors (#60) Sep 26, 2018
docs reliable RPC (#61) Oct 5, 2018
e2e e2e tests are working with grpc server/client 💪🏼 Jun 27, 2018
errors Do not overwrite pitaya error (#28) Jul 17, 2018
examples reliable RPC (#61) Oct 5, 2018
helpers e2e tests are working with grpc server/client 💪🏼 Jun 27, 2018
interfaces post-refactor tests Jun 27, 2018
internal refactor messages encoder Jun 18, 2018
logger Major bug fixes and refactor 💥 Apr 19, 2018
metrics reliable RPC (#61) Oct 5, 2018
mocks Add new field GetName on serializer interface (#27) Jul 17, 2018
modules refactor modules, create base Aug 1, 2018
pipeline Pipeline now receives the decoded arguments insted of raw data (#41) Aug 16, 2018
pitaya-protos @ 6af95f1 Update submodule (#57) Sep 17, 2018
protos Kick refactor (#43) Aug 17, 2018
remote refactor protos Jun 27, 2018
route Handler service tests. Apr 20, 2018
router Additional Tags and routingFunc (#55) Sep 13, 2018
serialize Add new field GetName on serializer interface (#27) Jul 17, 2018
service save client's ip version on session (#63) Oct 5, 2018
session Fix nats subscription leak (#48) Aug 24, 2018
timer Major bug fixes and refactor 💥 Apr 19, 2018
tracing fix jaeger tracing Jul 18, 2018
util Add default logger to context on both handlers and remotes (#44) Aug 20, 2018
worker reliable RPC (#61) Oct 5, 2018
.gitignore [WIP] GRPC mode Jun 27, 2018
.gitmodules more protos refactor Jun 27, 2018
.travis.yml more protos refactor Jun 27, 2018
Gopkg.lock reliable RPC (#61) Oct 5, 2018
Gopkg.toml reliable RPC (#61) Oct 5, 2018
LICENSE update license Mar 20, 2018
Makefile reliable RPC (#61) Oct 5, 2018
README.md Updated readme example (#33) Aug 7, 2018
app.go Fix log message (#64) Oct 8, 2018
app_test.go reliable RPC (#61) Oct 5, 2018
component.go Some typos Apr 19, 2018
component_test.go Unit tests for pitaya package Apr 10, 2018
group.go Initial docs Jul 17, 2018
group_test.go Unit tests for pitaya package Apr 10, 2018
kick.go reliable RPC (#61) Oct 5, 2018
kick_test.go Push and kick fix ( Closes #51 ) (#56) Sep 17, 2018
module.go ordered modules (#39) Aug 14, 2018
module_test.go ordered modules (#39) Aug 14, 2018
pipeline.go Fix pipeline. Mar 20, 2018
pipeline_test.go Pipeline now receives the decoded arguments insted of raw data (#41) Aug 16, 2018
push.go Push and kick fix ( Closes #51 ) (#56) Sep 17, 2018
push_test.go Push and kick fix ( Closes #51 ) (#56) Sep 17, 2018
rpc.go reliable RPC (#61) Oct 5, 2018
rpc_test.go Feature/docs (#30) Jul 23, 2018
timer.go Unit tests for pitaya package Apr 10, 2018
timer_test.go Unit tests for pitaya package Apr 10, 2018

README.md

pitaya Build Status Coverage Status GoDoc Docs Go Report Card MIT licensed

Pitaya is an easy to use, fast and lightweight game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK. The goal of pitaya is to provide a basic development framework for distributed multiplayer games and server-side applications.

Getting Started

Prerequisites

  • Go >= 1.10
  • etcd (used for service discovery)
  • nats (optional, it's used for sending and receiving rpc, you can use grpc implementations too if you prefer)
  • docker (optional: for running etcd and nats dependencies on containers)

Installing

clone the repo

git clone https://github.com/topfreegames/pitaya.git

setup pitaya dependencies

make setup

Hacking pitaya

Here's how to run one of the examples:

Start etcd (this command requires docker-compose and will run an etcd container locally, you may run an etcd without docker if you prefer)

cd ./examples/testing && docker-compose up -d etcd

run the connector frontend server from cluster_grpc example

make run-cluster-grpc-example-connector

run the room backend server from the cluster_grpc example

make run-cluster-grpc-example-room

You should now have 2 pitaya servers running, a frontend connector and a backend room. You can then use pitaya-cli a REPL client for pitaya for sending some requests:

$ pitaya-cli
Pitaya REPL Client
>>> connect localhost:3250
connected!
>>> request room.room.entry
>>> sv-> {"code":0,"result":"ok"}

Running the tests

make test

This command will run both unit and e2e tests.

Deployment

#TODO

Contributing

#TODO

Authors

  • TFG Co - Initial work

License

MIT License

Acknowledgements

  • nano authors for building the framework pitaya is based on.
  • pomelo authors for the inspiration on the distributed design and protocol

Resources

Benchmarks

using grpc

===============RUNNING BENCHMARK TESTS WITH GRPC===============
--- starting testing servers
--- sleeping for 5 seconds
goos: darwin
goarch: amd64
BenchmarkCreateManyClients-30                                              	    2000	    732922 ns/op
BenchmarkFrontHandlerWithSessionAndRawReturnsRaw-30                        	    2000	    712525 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtr-30                        	    2000	    704867 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrManyClientsParallel-30     	    2000	    647892 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrParallel-30                	    2000	    692803 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtr-30                          	    2000	    880599 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtrParallel-30                  	    2000	    630234 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtr-30                           	    1000	   1123467 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallel-30                   	    2000	    667119 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallelMultipleClients-30    	    2000	    664865 ns/op

using nats

===============RUNNING BENCHMARK TESTS WITH NATS===============
--- starting testing servers
--- sleeping for 5 seconds
goos: darwin
goarch: amd64
BenchmarkCreateManyClients-30                                              	    2000	    873214 ns/op
BenchmarkFrontHandlerWithSessionAndRawReturnsRaw-30                        	    2000	    702125 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtr-30                        	    2000	    794028 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrManyClientsParallel-30     	    2000	    769600 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrParallel-30                	    2000	    702894 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtr-30                          	    2000	    984978 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtrParallel-30                  	    2000	    699000 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtr-30                           	    1000	   1945727 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallel-30                   	    2000	    784496 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallelMultipleClients-30    	    2000	    846923 ns/op