snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
test / Lint (push) Failing after 3s
test / Test with Go 1.26.8 (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:17:21 +05:00
commit b352a9a30d
472 changed files with 108375 additions and 0 deletions

31
internal/pubsub/config.go Normal file
View File

@@ -0,0 +1,31 @@
package pubsub
import (
"fmt"
"github.com/centrifugal/centrifugo/v6/internal/configtypes"
)
// Config configures PubSub creation.
type Config struct {
// Type selects the backend: "redis" (default) or "nats".
Type string
// Channel is the notification channel/subject name. Prefix is applied automatically.
Channel string
// Redis connection config. Used when Type is "redis".
Redis configtypes.RedisEmptyPrefixed
// Nats connection config. Used when Type is "nats".
Nats configtypes.NatsEmptyPrefixed
}
// New creates a PubSub instance from config.
func New(cfg Config) (PubSub, error) {
switch cfg.Type {
case "", "redis":
return NewRedisPubSub(cfg.Redis, cfg.Channel)
case "nats":
return NewNatsPubSub(cfg.Nats, cfg.Channel)
default:
return nil, fmt.Errorf("unknown pubsub type: %q", cfg.Type)
}
}