summaryrefslogtreecommitdiff
path: root/events/grpc_event.go
blob: 31ff495782aefa4492504ac4708dd07e3ddf28a9 (plain)
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
package events

import (
	"time"

	"google.golang.org/grpc"
)

const (
	// EventUnaryCallOk represents success unary call response
	EventUnaryCallOk G = iota + 13000

	// EventUnaryCallErr raised when unary call ended with error
	EventUnaryCallErr
)

type G int64

func (ev G) String() string {
	switch ev {
	case EventUnaryCallOk:
		return "EventUnaryCallOk"
	case EventUnaryCallErr:
		return "EventUnaryCallErr"
	}
	return UnknownEventType
}

// JobEvent represent job event.
type GRPCEvent struct {
	Event G
	// Info contains unary call info.
	Info *grpc.UnaryServerInfo
	// Error associated with event.
	Error error
	// event timings
	Start   time.Time
	Elapsed time.Duration
}