feat: Use snowflake identifiers
All checks were successful
/ pre-commit (push) Successful in 1m7s

Fixes #29.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-09-20 08:37:16 +02:00
commit 2c3ca08dbf
Signed by: jriou
GPG key ID: 9A099EDA51316854
9 changed files with 24 additions and 39 deletions

View file

@ -10,7 +10,7 @@ type Config struct {
Title string `json:"title"`
DatabaseType string `json:"database_type"`
DatabaseDsn string `json:"database_dsn"`
IDLength int `json:"id_length"`
NodeID int64 `json:"node_id"`
PasswordLength int `json:"password_length"`
ExpirationInterval int `json:"expiration_interval"`
ListenAddress string `json:"listen_address"`
@ -36,7 +36,7 @@ func NewConfig() *Config {
Title: "Coller",
DatabaseType: "sqlite",
DatabaseDsn: "collerd.db",
IDLength: 5,
NodeID: 1,
PasswordLength: 16,
ExpirationInterval: 60, // 1 minute
ListenAddress: "0.0.0.0",
@ -88,8 +88,8 @@ func (c *Config) Check() error {
}
}
if c.IDLength <= 0 {
return fmt.Errorf("identifiers length must be greater than zero")
if c.NodeID < 0 || c.NodeID > 1023 {
return fmt.Errorf("node id must be between 0 and 1023")
}
if c.PasswordLength < internal.MIN_PASSWORD_LENGTH || c.PasswordLength > internal.MAX_PASSWORD_LENGTH {