pubsub/init.go

gitea · services/pubsub/init.go · go · MIT
realtime

Copyright 2026 The Gitea Authors. All rights reserved. SPDX-License-Identifier: MIT

// Source: https://github.com/go-gitea/gitea | License: MIT | Copyright 2016 The Gitea Authors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package pubsub

import (
	"fmt"

	"gitea.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)
		}
		De

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key