server

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

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 WithClusterRegion(region string) Option

func WithKeyPrefix

func WithKeyPrefix(prefix string) Option

func WithListenAddr

func WithListenAddr(addr string) Option

func WithLockAutoExtend

func WithLockAutoExtend(d time.Duration) Option

func WithLockTTL

func WithLockTTL(d time.Duration) Option

func WithLogger

func WithLogger(l gochainedlog.Logger) Option

func WithMaxConcurrency

func WithMaxConcurrency(n int) Option

func WithNodeID

func WithNodeID(id string) Option

func WithRedisCluster

func WithRedisCluster(addrs []string) Option

WithRedisCluster configures Redis Cluster mode.

func WithRedisDB

func WithRedisDB(db int) Option

WithRedisDB sets the Redis database number.

func WithRedisPassword

func WithRedisPassword(password string) Option

WithRedisPassword sets the Redis password.

func WithRedisPoolSize

func WithRedisPoolSize(n int) Option

WithRedisPoolSize sets the Redis connection pool size.

func WithRedisSentinel

func WithRedisSentinel(masterName string, sentinelAddrs []string, sentinelPassword string) Option

WithRedisSentinel configures Redis Sentinel failover mode.

func WithRedisURL

func WithRedisURL(url string) Option

WithRedisURL sets the Redis server URL.

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) Option

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

func New(opts ...Option) (*Server, error)

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

func (s *Server) RedisClient() rueidis.Client

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) Start

func (s *Server) Start(ctx context.Context) error

Start connects to Redis, initializes the actor system, and begins operation.

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully shuts down the server.

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.

func (*Server) Worker

func (s *Server) Worker() *worker.Worker

Worker returns nil for the actor-model server (no v1 Worker). dureqd checks `if w := srv.Worker(); w != nil` before using it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL