Documentation
¶
Index ¶
- type Config
- type Option
- func WithClusterRegion(region string) Option
- func WithKeyPrefix(prefix string) Option
- func WithListenAddr(addr string) Option
- func WithLockAutoExtend(d time.Duration) Option
- func WithLockTTL(d time.Duration) Option
- func WithLogger(l gochainedlog.Logger) Option
- func WithMaxConcurrency(n int) Option
- func WithNodeID(id string) Option
- func WithPriorityTiers(tiers []store.TierConfig) Option
- func WithRedisCluster(addrs []string) Option
- func WithRedisDB(db int) Option
- func WithRedisPassword(password string) Option
- func WithRedisPoolSize(n int) Option
- func WithRedisSentinel(masterName string, sentinelAddrs []string, sentinelPassword string) Option
- func WithRedisURL(url string) Option
- func WithShutdownTimeout(d time.Duration) Option
- type Server
- func (s *Server) Dispatcher() monitor.Dispatcher
- func (s *Server) Middlewares() []types.MiddlewareFunc
- func (s *Server) RedisClient() rueidis.Client
- func (s *Server) RegisterHandler(def types.HandlerDefinition) error
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop() error
- func (s *Server) Store() *store.RedisStore
- func (s *Server) Use(mw ...types.MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Redis connection options.
RedisOptions types.RedisOptions
// NodeID uniquely identifies this server node. Auto-generated if empty.
NodeID string
// ListenAddr is the address for Hollywood Remote (dRPC). Default: random port.
ListenAddr string
// ClusterRegion is the cluster region identifier. Default: "default".
ClusterRegion string
// MaxConcurrency is the overall worker pool size per node. Default: 100.
MaxConcurrency int
// ShutdownTimeout is the grace period for in-flight tasks before abort.
// Default: 30s.
ShutdownTimeout time.Duration
// LockTTL is the distributed lock TTL for per-run locks. Default: 30s.
LockTTL time.Duration
// LockAutoExtend is the interval for auto-extending per-run locks. Default: LockTTL/3.
LockAutoExtend time.Duration
// StoreConfig holds Redis store configuration.
StoreConfig store.RedisStoreConfig
// Logger is the structured logger. Default: slog.Default().
Logger gochainedlog.Logger
}
Config holds all server configuration for dureq (Hollywood actor-based).
type Option ¶
type Option func(*Config)
Option configures the server.
func WithClusterRegion ¶
func WithKeyPrefix ¶
func WithListenAddr ¶
func WithLockAutoExtend ¶
func WithLockTTL ¶
func WithLogger ¶
func WithLogger(l gochainedlog.Logger) Option
func WithMaxConcurrency ¶
func WithNodeID ¶
func WithPriorityTiers ¶ added in v0.1.2
func WithPriorityTiers(tiers []store.TierConfig) Option
WithPriorityTiers sets the priority tier configuration.
func WithRedisCluster ¶
WithRedisCluster configures Redis Cluster mode.
func WithRedisPassword ¶
WithRedisPassword sets the Redis password.
func WithRedisPoolSize ¶
WithRedisPoolSize sets the Redis connection pool size.
func WithRedisSentinel ¶
WithRedisSentinel configures Redis Sentinel failover mode.
func WithShutdownTimeout ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the dureq server node built on the Hollywood actor framework. It replaces the v1 pull/polling model with a push-based actor model.
func New ¶
New creates a new dureq server with the given options. Call RegisterHandler to add task types, then Start to begin.
func (*Server) Dispatcher ¶
func (s *Server) Dispatcher() monitor.Dispatcher
Dispatcher returns the actor-model Dispatcher that satisfies monitor.Dispatcher. Available after Start().
func (*Server) Middlewares ¶
func (s *Server) Middlewares() []types.MiddlewareFunc
Middlewares returns the registered global middleware chain.
func (*Server) RedisClient ¶
RedisClient returns the Redis client. Available after Start().
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler(def types.HandlerDefinition) error
RegisterHandler registers a task type handler on this server. Must be called before Start.
func (*Server) Store ¶
func (s *Server) Store() *store.RedisStore
Store returns the Redis store. Available after Start().
func (*Server) Use ¶
func (s *Server) Use(mw ...types.MiddlewareFunc)
Use adds global middleware that wraps every handler. Must be called before Start. Middlewares are applied in order: first added = outermost.