-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (51 loc) · 1.45 KB
/
main.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
57
58
// Copyright (c) 2016 IBM Corp. All rights reserved.
// Use of this source code is governed by the Apache License,
// Version 2.0, a copy of which can be found in the LICENSE file.
// Main - it all starts here.
package main
import (
"crypto/tls"
"flag"
"fmt"
"net/http"
)
// We operate in one of two modes:
// - for a delete request, we get the work done and exit the program
// - for a registration request, we register the room and then run
// a server to handle websocket callbacks. Currently this server
// runs pretty much forever until the program is killed.
func main() {
locus := "MAIN"
checkpoint(locus, "processCommandLine")
err := processCommandline()
if err != nil {
fmt.Println(err.Error())
flag.Usage()
return
}
printConfig(&config)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
if len(config.roomToDelete) > 0 {
checkpoint(locus, fmt.Sprintf("deleteWithRetries %s", config.roomToDelete))
err = deleteWithRetries(client, config.roomToDelete)
if err != nil {
checkpoint(locus, fmt.Sprintf("DELETE.FAILED err=%s", err.Error()))
}
return
}
checkpoint(locus, "registerWithRetries")
err = registerWithRetries(client)
if err != nil {
fmt.Printf(err.Error())
return
}
checkpoint(locus, "startServer")
startServer()
}
// Prints a simple checkpoint message.
func checkpoint(locus, s string) {
fmt.Printf("CHECKPOINT: %s.%s\n", locus, s)
}