This file is indexed.

/usr/share/gocode/src/github.com/hashicorp/serf/command/agent/event_handler_mock.go is in golang-github-hashicorp-serf-dev 0.7.0~ds1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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 agent

import (
	"github.com/hashicorp/serf/serf"
	"sync"
)

// MockEventHandler is an EventHandler implementation that can be used
// for tests.
type MockEventHandler struct {
	Events []serf.Event
	sync.Mutex
}

func (h *MockEventHandler) HandleEvent(e serf.Event) {
	h.Lock()
	defer h.Unlock()
	h.Events = append(h.Events, e)
}

// MockQueryHandler is an EventHandler implementation used for tests,
// it always responds to a query with a given response
type MockQueryHandler struct {
	Response []byte
	Queries  []*serf.Query
	sync.Mutex
}

func (h *MockQueryHandler) HandleEvent(e serf.Event) {
	query, ok := e.(*serf.Query)
	if !ok {
		return
	}

	h.Lock()
	h.Queries = append(h.Queries, query)
	h.Unlock()

	query.Respond(h.Response)
}