-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.go
56 lines (48 loc) · 1.17 KB
/
common.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package mermaidlive
import (
"fmt"
"os"
"github.com/evanw/esbuild/pkg/api"
)
const Topic = "events"
const InternalTopic = "internal-events"
const ClusterMessageTopic = "cluster-events"
const NewConnectionsCounter = "newconnections"
const StartedConnectionsCounter = "started-connections"
const ClosedConnectionsCounter = "closed-connections"
const VisitorJoinedEvent = "VisitorJoined"
const VisitorLeftEvent = "VisitorLeft"
const VisitorsActiveEvent = "VisitorsActive"
const ClusterMessageEvent = "ClusterMessage"
const TotalVisitorsEvent = "TotalVisitors"
const TotalClusterVisitorsActiveEvent = "TotalClusterVisitorsActive"
const SourceReplicaIdKey = "Source-Replica-Id"
type PeerLocator interface {
GetPeers() ([]string, int, error)
GetMyIP() string
}
var DoEmbed = false
var ClusterObservabilityEnabled = false
func crashOnError(err error) {
if err != nil {
panic(err)
}
}
func handleErrors(errors []api.Message) {
for _, msg := range errors {
if msg.Location != nil {
fmt.Printf(
"%s:%v:%v: %s\n",
msg.Location.File,
msg.Location.Line,
msg.Location.Column,
msg.Text,
)
} else {
fmt.Println(msg)
}
}
if len(errors) > 0 {
os.Exit(1)
}
}