Home

Awesome

Pitaya Admin Build Status GoDoc Go Report Card MIT licensed

Pitaya's games management and monitoring interface

Getting Started

Setup dependencies (make sure you have dep installed)

make setup

Start pitaya admin

make run

API

Errors

Whenever pitaya admin responds with an error, it will be in the following format:

{"success":false, "message":[msg], "reason": [error]}

Client Request

Establishes a websocket connection with pitaya admin that can be used to send requests to handlers and receive theirs outputs through a pitaya client connected to given server address.

Documentation

Returns server auto documentation given its type. Target server must implement pitaya's auto documentation remote. The documentation remote is usefull on servers that have many handlers and remotes.

func (c *ConnectorRemote) Docs(ctx context.Context, flag *protos.DocMsg) (*protos.Doc, error) {
    d, err := pitaya.Documentation(flag.GetGetProtos())

    if err != nil {
        return nil, err
    }
    doc, err := json.Marshal(d)

    if err != nil {
        return nil, err
    }

    return &protos.Doc{Doc: string(doc)}, nil
}

The boolean inside flag passed to pitaya.Documentation specifies if the documentation will have protobuf message names. Note that in order to pitaya admin RPC to work, documentation must have protos name.

Kick Users

Send a kick packet to users in a given user list, breaking the users connections to the pitaya server

List Servers

Returns a json array with servers information

RPC

Sends a RPC to a pitaya server. Target server must implement remotes for protobuf descriptors and auto documentation.

func (c *ConnectorRemote) Docs(ctx context.Context, flag *protos.DocMsg) (*protos.Doc, error) {
    d, err := pitaya.Documentation(flag.GetGetProtos())

    if err != nil {
        return nil, err
    }

    doc, err := json.Marshal(d)

    if err != nil {
        return nil, err
    }

    return &protos.Doc{Doc: string(doc)}, nil
}

func (c *ConnectorRemote) Proto(ctx context.Context, message *protos.ProtoName) (*protos.ProtoDescriptor, error) {
    protoDescriptor, err := pitaya.Descriptor(message.GetName())

    if err != nil {
        return nil, err
    }

    return &protos.ProtoDescriptor{
        Desc: protoDescriptor,
    }, nil
}

All of the used protobuf messages can be found at pitaya-protos. You can implement the remotes on your own components as shown above, or you can use the components defined at the package remotes.

Send Push

Sends a push notification to users in a given user list

Configuring Pitaya Admin

In order for Pitaya Admin to work, the following configuration must be set using environment variables or passing it through a .yaml configuration file.

Example yaml config:

routes:
  protos: "protoRemote.proto"
  docs: "docRemote.docs"
request:
  whitelist:
    - localhost:8080
  readdeadline: 5m

If environment variables are used, their prefix must be PITAYAADMIN. It is important to note that you also have to setup Pitaya configuration such as etcd configs according to your needs.

License

MIT License