forked from konveyor/analyzer-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (52 loc) · 1.33 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
59
60
61
62
63
64
65
package main
import (
"context"
"fmt"
"os"
"github.com/shawn-hurley/jsonrpc-golang/engine"
"github.com/shawn-hurley/jsonrpc-golang/parser"
"github.com/shawn-hurley/jsonrpc-golang/provider"
"github.com/shawn-hurley/jsonrpc-golang/provider/lib"
)
const (
// This must eventually be a default that makes sense, and overrideable by env var or flag.
SETTING_FILE_PATH = "./provider_settings.json"
RULES_FILE_PATH = "./rule-example.json"
)
func main() {
ctx := context.Background()
// Get the configs
configs, err := lib.GetConfig(SETTING_FILE_PATH)
if err != nil {
fmt.Printf("\n%v\n", err)
os.Exit(1)
}
//start up the rule engine
engine := engine.CreateRuleEngine(ctx, 10)
providers := map[string]provider.Client{}
for _, config := range configs {
provider, err := provider.GetProviderClient(config)
if err != nil {
fmt.Printf("\n%v\n", err)
os.Exit(1)
}
providers[config.Name] = provider
}
parser := parser.RuleParser{
ProviderNameToClient: providers,
}
rules, needProviders, err := parser.LoadRules(RULES_FILE_PATH)
if err != nil {
fmt.Printf("\n%v\n", err)
os.Exit(1)
}
// Now that we have all the providers, we need to start them.
for _, provider := range needProviders {
err := provider.Init(ctx)
if err != nil {
fmt.Printf("\n%v\n", err)
os.Exit(1)
}
}
engine.RunRules(ctx, rules)
}