https://github.com/queer/amybot-shards
https://github.com/queer/amybot-shards
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/queer/amybot-shards
- Owner: queer
- Created: 2017-09-05T09:55:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-25T08:53:29.000Z (about 8 years ago)
- Last Synced: 2025-06-09T22:58:47.625Z (12 months ago)
- Language: Java
- Size: 130 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# amybot shards
The magical thing that dumps Discord events into the backend. :tm:

Much thanks to [Shredder121](https://github.com/shredder121) for yelling at me when I make dumb decisions, and for generally being awesome.
Due to some needs of mine, this is also a Discord API library, of sorts. Eventually I'll be able to replace JDA, but not any time soon
## Badges
[](http://forthebadge.com)
[](http://forthebadge.com)
[](http://forthebadge.com)
[](http://forthebadge.com)
[](http://forthebadge.com)
[](http://forthebadge.com)
## Current TODO list
- Finish mechanisms for building caches out of Discord events
- Make sure that snowflake ZSET caches are actually updated
- Make sure that tests actually pass
- Abstract out the messenger layer a bit better so that I can drop in RMQ support later
## How is everything connected?
This simple graph should explain it all quite nicely

The key takeaway here is that Graphviz is hard to do right. :thumbsup:
## wtf is wrong with you
Well JDA didn't support what I wanted, and external caching + raw mWS event access is nice.
## Configuration
Configuration is done through environment variables.
```bash
# The token for your bot
BOT_TOKEN="no default provided, obviously"
# Your redis host address. Default is 'redis'
REDIS_HOST="redis"
# The password to your redis host. This is a requirement
REDIS_PASS="a"
# How to derive shard id / scale. Default method is the Rancher metadata service, but may also be configured through environment variables
# Possible values: "rancher", "env"
SHARDING_METHOD="rancher"
# Used when SHARDING_METHOD="env"
SHARD_ID=15
# Used when SHARDING_METHOD="env"
SHARD_SCALE=27
```
## Other
### Some thoughts on caching
- **Redisson is not used anymore.** While unfortunate, this decision was made because Redisson was just like "lol what is serializing correctly :S" and decided to blow it up using the Jackson codec.
- All guilds have their own object in the cache
- All users have their own object in the cache
- All members lists are a part of their respective guild objects, as a set of Member objects
- Member objects reference their user object by snowflake
- Building initial caches is pretty heavily abusive to the redis server; make sure you're actually ready for this.
### Caching format
#### Single objects
Guild: `guild:snowflake:bucket`
User: `user:snowflake:bucket`
Member: `member:guild_snowflake:user_snowflake:bucket`
Channel: `channel:snowflake:bucket`
Role: `role:guild_snowflake:snowflake:bucket`
Emote: `emote:guild_snowflake:snowflake:bucket`
#### Snowflake sets
Users: `user:sset`
Guilds: `guild:sset`
Members: `member:guild_snowflake:sset`?
Channels: `channel:sset`
Roles: `role:sset`
Emotes: `emote:sset`