Skip to content

zevaryx/shardman

Repository files navigation

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

Status Meaning Description Schema
200 OK Successful Response ConnectConfirmed
401 Unauthorized No Shards Available None
403 Forbidden Invalid Token None
422 Unprocessable Entity Validation Error HTTPValidationError

POST /beat

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

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

print(r.json())

Parameters

Name In Type Required Description
session_id data string true Session ID provided by /connect
guild_count data int false Number of guilds the shard sees
latency data float false Current shard latency
extra data Any false Extra data to store for shard

Example responses

422 Response

{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
204 No Content Successful Response None
401 Unauthorized No Shards Available None
403 Forbidden Invalid Token None
404 Not Found Session Not Found None
422 Unprocessable Entity Validation Error HTTPValidationError

Schemas

ConnectConfirmed

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

ConnectConfirmed

Properties

Name Type Required Restrictions Description
shard_id integer true none Shard ID to connect with
max_shards integer true none Max number of shards
session_id string true none Session ID for /beat

HTTPValidationError

{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}

HTTPValidationError

Properties

Name Type Required Restrictions Description
detail ValidationError false none none
{
  "loc": [
    "string"
  ],
  "msg": "string",
  "type": "string"
}

ValidationError

Properties

Name Type Required Restrictions Description
loc [anyOf] true none none

anyOf

Name Type Required Restrictions Description
» anonymous string false none none

or

Name Type Required Restrictions Description
» anonymous integer false none none

continued

Name Type Required Restrictions Description
msg string true none none
type string true none none

About

Shard Management Utility for Discord bots

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published