Skip to content

Commit

Permalink
refactor(Cluster): remove bots from pricing model
Browse files Browse the repository at this point in the history
Backwards compatible because we ignore byte 4 now
  • Loading branch information
fubuloubu authored Feb 1, 2025
1 parent 0ac1847 commit 0cf1f8e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions silverback/cluster/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class ClusterConfiguration(BaseModel):
# NOTE: Update this to revise new models for every configuration change
version: int = 1

# Bot Worker Configuration, priced per bot (Bytes 1-2)
# Cluster-wide Configuration, priced per maximum usage (Bytes 1-2)
cpu: Annotated[int, Field(ge=0, le=6)] = 0 # defaults to 0.25 vCPU
"""Allocated vCPUs per bot:
"""Max vCPUs for entire cluster:
- 0.25 vCPU (0)
- 0.50 vCPU (1)
- 1.00 vCPU (2)
Expand All @@ -49,22 +49,21 @@ class ClusterConfiguration(BaseModel):
- 16.0 vCPU (6)"""

memory: Annotated[int, Field(ge=0, le=120)] = 0 # defaults to 512 MiB
"""Total memory per bot (in GB, 0 means '512 MiB')"""
"""Max memory for entire cluster (in GB, 0 means '512 MiB')"""

# NOTE: # of workers configured based on cpu & memory settings

# Runner configuration (Bytes 3-4)
networks: Annotated[int, Field(ge=1, le=20)] = 1
"""Maximum number of concurrent network runners"""

bots: Annotated[int, Field(ge=1, le=250)] = 1
"""Maximum number of concurrent running bots"""
# NOTE: Byte 4 unused

# NOTE: Byte 5 unused

# Recorder configuration (Bytes 6-7)
bandwidth: Annotated[int, Field(ge=0, le=250)] = 0 # 512 kB/sec
"""Rate at which data should be emitted by cluster (in MB/sec, 0 means '512 kB')"""
"""Rate at which data should be emitted by cluster (in MB/sec, 0 means '512 kB/sec')"""
# NOTE: This rate is only estimated average, and will serve as a throttling threshold

duration: Annotated[int, Field(ge=1, le=120)] = 1
Expand Down Expand Up @@ -111,7 +110,6 @@ def settings_display_dict(self) -> dict:
version=self.version,
runner=dict(
networks=self.networks,
bots=self.bots,
),
bots=dict(
cpu=f"{256 * 2**self.cpu / 1024} vCPU",
Expand Down Expand Up @@ -147,7 +145,6 @@ def decode(cls, value: Any) -> "ClusterConfiguration":
cpu=cls._decode_byte(value, 1),
memory=cls._decode_byte(value, 2),
networks=cls._decode_byte(value, 3),
bots=cls._decode_byte(value, 4),
bandwidth=cls._decode_byte(value, 6),
duration=cls._decode_byte(value, 7),
)
Expand All @@ -168,7 +165,6 @@ def encode(self) -> int:
+ self._encode_byte(self.cpu, 1)
+ self._encode_byte(self.memory, 2)
+ self._encode_byte(self.networks, 3)
+ self._encode_byte(self.bots, 4)
+ self._encode_byte(self.bandwidth, 6)
+ self._encode_byte(self.duration, 7)
)
Expand Down Expand Up @@ -214,15 +210,13 @@ class ClusterTier(enum.IntEnum):
cpu="0.25 vCPU",
memory="512 MiB",
networks=3,
bots=5,
bandwidth="512 B/sec", # 1.236 GB/mo
duration=3, # months
).encode()
PREMIUM = ClusterConfiguration(
cpu="1 vCPU",
memory="2 GB",
networks=10,
bots=20,
bandwidth="5 kB/sec", # 12.36 GB/mo
duration=12, # 1 year = ~148GB
).encode()
Expand Down

0 comments on commit 0cf1f8e

Please sign in to comment.