Files
gotea/services/pubsub/init.go
T
lotherk 1b490485ff refactor: import Gotea from Gitea v28.4.0
Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
2026-11-22 12:13:09 +00:00

30 lines
767 B
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pubsub
import (
"fmt"
"gotea.dev/modules/setting"
)
// Init replaces DefaultBroker according to setting.Websocket. Called from
// websocket.Init before the notifier is registered so subscribers wire up to
// the configured backend.
func Init() error {
switch setting.Websocket.PubsubType {
case setting.PubsubTypeMemory:
DefaultBroker = NewMemoryBroker()
case setting.PubsubTypeRedis:
b, err := NewRedisBroker(setting.Websocket.PubsubConnStr)
if err != nil {
return fmt.Errorf("pubsub: init redis backend: %w", err)
}
DefaultBroker = b
default:
return fmt.Errorf("pubsub: unknown PUBSUB_TYPE %q", setting.Websocket.PubsubType)
}
return nil
}