Skip to content

P3: Make NumShards configurable #28

@U0001F3A2

Description

@U0001F3A2

Problem

NumShards is hardcoded as a constant:

const (
    NumShards = 6  // TODO: make configurable
    ...
)

This limits flexibility for testing with different shard counts and production deployments.

Current Behavior

Fixed at 6 shards, cannot be changed without code modification and rebuild.

Proposed Solution

Make NumShards configurable via:

  1. Environment variable (e.g., SHARD_COUNT)
  2. Config file (config/config.json)
  3. Command-line flag

Implementation

// In config package
type Config struct {
    NumShards int `json:"num_shards"`
    // ...
}

// In server.go
var NumShards = config.GetNumShards()  // Default 6 if not set

Considerations

  • Shard ID calculation uses modulo: shardID = address % NumShards
  • All nodes must use same NumShards value
  • Changing NumShards requires state migration (not supported initially)

Priority

P3 - Nice-to-have for flexibility. Current hardcoded value works for development.

Location

internal/shard/server.go:967

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Medium priority - fix when possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions