File: null.go

package info (click to toggle)
receptor 1.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,772 kB
  • sloc: python: 1,643; makefile: 305; sh: 174
file content (40 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package backends

import (
	"context"
	"crypto/tls"
	"sync"

	"github.com/ansible/receptor/pkg/netceptor"
)

type NullBackendCfg struct {
	Local bool
}

// make the nullBackendCfg object be usable as a do-nothing Backend.
func (cfg NullBackendCfg) Start(_ context.Context, _ *sync.WaitGroup) (chan netceptor.BackendSession, error) {
	return make(chan netceptor.BackendSession), nil
}

// Run runs the action, in this case adding a null backend to keep the wait group alive.
func (cfg NullBackendCfg) Run() error {
	err := netceptor.MainInstance.AddBackend(&NullBackendCfg{})
	if err != nil {
		return err
	}

	return nil
}

func (cfg *NullBackendCfg) GetAddr() string {
	return ""
}

func (cfg *NullBackendCfg) GetTLS() *tls.Config {
	return nil
}

func (cfg NullBackendCfg) Reload() error {
	return cfg.Run()
}