Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

common

Shared library for PurgeBot services. Contains the purge job definition, Redis queue helpers, and logging setup.

Packages

job

Purge job type, Redis queue operations, and guild locking.

import "github.com/PurgeBot-net/common/job"

// Enqueue a job from the interactions service
err := job.Enqueue(ctx, rdb, &job.PurgeJob{ ... })

// Dequeue a job in the purge worker (blocks up to timeout)
j, err := job.Dequeue(ctx, rdb, 5*time.Second)

// Claim the guild's active job slot (one active purge per guild)
claimed, err := job.SetActiveJob(ctx, rdb, j)
job.DeleteActiveJob(ctx, rdb, guildID)

// Cancel a running job
job.Cancel(ctx, rdb, jobID)
job.IsCancelled(ctx, rdb, jobID)

log

Zap logger with optional Sentry integration.

import "github.com/PurgeBot-net/common/log"

logger, err := log.New(os.Getenv("LOG_LEVEL"), os.Getenv("LOG_JSON") == "true")
logger = log.WithSentry(logger, os.Getenv("SENTRY_DSN"))

rdb

Redis client constructor with a startup ping.

import "github.com/PurgeBot-net/common/rdb"

client, err := rdb.New(
    os.Getenv("REDIS_ADDR"),
    os.Getenv("REDIS_PASSWORD"),
    0,
)

About

Shared Go library with the job queue, logging and Redis client used by all PurgeBot services

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages