GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( a5aa25...c55ba3 )
by Amir
01:20
created

main.*server.Get   A

Complexity

Conditions 4

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nop 2
dl 0
loc 14
rs 9.85
c 0
b 0
f 0
1
package main
2
3
import (
4
	"flag"
5
	"fmt"
6
	"github.com/arazmj/gerdu/cache"
7
	"github.com/arazmj/gerdu/grpcserver"
8
	"github.com/arazmj/gerdu/httpserver"
9
	"github.com/arazmj/gerdu/lfucache"
10
	"github.com/arazmj/gerdu/lrucache"
11
	"github.com/arazmj/gerdu/weakcache"
12
	"github.com/inhies/go-bytesize"
13
	"os"
14
	"strings"
15
	"sync"
16
)
17
18
var gerdu cache.UnImplementedCache
19
var wg = sync.WaitGroup{}
20
21
var (
22
	verbose     = flag.Bool("verbose", false, "verbose logging")
23
	capacityStr = flag.String("capacity", "64MB",
24
		"The size of cache, once cache reached this capacity old values will evicted.\n"+
25
			"Specify a numerical value followed by one of the following units (not case sensitive)"+
26
			"\nK or KB: Kilobytes"+
27
			"\nM or MB: Megabytes"+
28
			"\nG or GB: Gigabytes"+
29
			"\nT or TB: Terabytes")
30
	httpPort  = flag.Int("httpport", 8080, "the http server port number")
31
	grpcPort  = flag.Int("grpcport", 8081, "the grpc server port number")
32
	kind      = flag.String("type", "lru", "type of cache, lru or lfu, weak")
33
	protocols = flag.String("protocols", "http", "protocol grpc or http, multiple values can be selected seperated by comma")
34
	tlsKey    = flag.String("key", "", "SSL certificate private key")
35
	tlsCert   = flag.String("cert", "", "SSL certificate public key")
36
	secure    = len(*tlsCert) > 0 && len(*tlsKey) > 0
37
)
38
39
func main() {
40
	flag.Parse()
41
	capacity, _ := bytesize.Parse(*capacityStr)
42
43
	if strings.ToLower(*kind) == "lru" {
44
		gerdu = lrucache.NewCache(capacity)
45
	} else if strings.ToLower(*kind) == "lfu" {
46
		gerdu = lfucache.NewCache(capacity)
47
	} else if strings.ToLower(*kind) == "weak" {
48
		gerdu = weakcache.NewWeakCache()
49
	} else {
50
		fmt.Println("Invalid value for type")
51
		os.Exit(1)
52
	}
53
54
	*protocols = strings.ToLower(*protocols)
55
	if strings.Contains(*protocols, "http") {
56
		wg.Add(1)
57
		go func() {
58
			defer wg.Done()
59
			if secure {
60
				httpserver.HttpServeTLS(*httpPort, *tlsCert, *tlsKey, gerdu, *verbose)
61
			} else {
62
				httpserver.HttpServe(*httpPort, gerdu, *verbose)
63
			}
64
		}()
65
	}
66
	if strings.Contains(*protocols, "grpc") {
67
		wg.Add(1)
68
		go func() {
69
			defer wg.Done()
70
			if secure {
71
				grpcserver.GrpcServeTLS(*grpcPort, *tlsCert, *tlsKey, gerdu, *verbose)
72
			} else {
73
				grpcserver.GrpcServe(*grpcPort, gerdu, *verbose)
74
			}
75
		}()
76
	} else {
77
		fmt.Println("Invalid value for protocol")
78
		os.Exit(1)
79
	}
80
	wg.Wait()
81
}
82