mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(gateway): get node id from kubernetes
This commit is contained in:
parent
bfa0071f90
commit
44c5a2d106
2 changed files with 12 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use anyhow::anyhow;
|
||||
use futures::StreamExt;
|
||||
use libpk::{_config::ClusterSettings, runtime_config::RuntimeConfig};
|
||||
use metrics::counter;
|
||||
|
|
@ -48,6 +49,12 @@ pub fn create_shards(redis: fred::clients::RedisPool) -> anyhow::Result<Vec<Shar
|
|||
|
||||
let (start_shard, end_shard): (u32, u32) = if cluster_settings.total_shards < 16 {
|
||||
warn!("we have less than 16 shards, assuming single gateway process");
|
||||
if cluster_settings.node_id != 0 {
|
||||
return Err(anyhow!(
|
||||
"expecting to be node 0 in single-process mode, but we are node {}",
|
||||
cluster_settings.node_id
|
||||
));
|
||||
}
|
||||
(0, (cluster_settings.total_shards - 1).into())
|
||||
} else {
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue