Sign inSign up

zevaryx/shardman

By zevaryx

Updated over 3 years ago

A Discord bot shard manager API

Image
0

981

zevaryx/shardman repository overview

Shardman

A Discord shard manager to help with autoscaling shards based on load

How to use

On bot startup, make a request to /connect with the header Authorization: <secret>, where <secret> is the same as SECRET in your .env

Once you have connected with your shard, you'll need to make sure you make a request to /beat every few seconds, less than MAX_SECONDS specified in your .env

This will keep the shard alive and maintained in the manager, so new shards don't try to connect in its place.

API documentation

Note: all endpoints require the Authorization: <secret> header

GET /connect
import requests
headers = {
  'Accept': 'application/json',
  'Authorization': 'SECRET',
}

r = requests.get('/connect', headers = headers)

print(r.json())

Example responses

200 Response

{
  "shard_id": 0,
  "max_shards": 0,
  "session_id": "string"
}
Responses
StatusMeaningDescriptionSchema
200OKSuccessful ResponseConnectConfirmed
401UnauthorizedNo Shards AvailableNone
403ForbiddenInvalid TokenNone
422Unprocessable EntityValidation ErrorHTTPValidationError

POST /beat

import requests
headers = {
  'Accept': 'application/json',
  'Authorization': 'SECRET',
}

r = requests.post('/beat', data={
  'session_id': 'string'
}, headers = headers)

print(r.json())

Parameters
NameInTypeRequiredDescription
session_iddatastringtrueSession ID provided by /connect
guild_countdataintfalseNumber of guilds the shard sees
latencydatafloatfalseCurrent shard latency
extradataAnyfalseExtra data to store for shard

Example responses

422 Response

{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
Responses
StatusMeaningDescriptionSchema
204No ContentSuccessful ResponseNone
401UnauthorizedNo Shards AvailableNone
403ForbiddenInvalid TokenNone
404Not FoundSession Not FoundNone
422Unprocessable EntityValidation ErrorHTTPValidationError

Schemas

ConnectConfirmed
{
  "shard_id": 0,
  "max_shards": 0,
  "session_id": "string"
}

ConnectConfirmed

Properties
NameTypeRequiredRestrictionsDescription
shard_idintegertruenoneShard ID to connect with
max_shardsintegertruenoneMax number of shards
session_idstringtruenoneSession ID for /beat
HTTPValidationError
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}

HTTPValidationError

Properties
NameTypeRequiredRestrictionsDescription
detailValidationErrorfalsenonenone
{
  "loc": [
    "string"
  ],
  "msg": "string",
  "type": "string"
}

ValidationError

Properties
NameTypeRequiredRestrictionsDescription
loc[anyOf]truenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousintegerfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
msgstringtruenonenone
typestringtruenonenone

Tag summary

Content type

Image

Digest

sha256:0b0c36225

Size

110.1 MB

Last updated

over 3 years ago

docker pull zevaryx/shardman