-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 1001 Bytes
/
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
package main
import (
"fmt"
"github.com/c3sr/dlframework"
cmd "github.com/c3sr/dlframework/framework/cmd/server"
"io/ioutil"
"mock-agent/mockagent"
"os"
)
func main() {
fmt.Println("Starting up Mock-Agent...")
framework := mockagent.FrameworkManifest
mockWorkHandler := MockWork{}
rootCmd, err := cmd.NewMqWorkerServer(framework, mockWorkHandler)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
fmt.Println("Clean Exit.")
}
type MockWork struct{
}
func (m MockWork) ProcessJob(incomingRequest string, manifest dlframework.FrameworkManifest) (string, error) {
fmt.Println("New Job : " + incomingRequest)
filenameToUse := os.Getenv("MOCK_FILE")
if filenameToUse == "" {
filenameToUse = "classification.json"
}
data, err := ioutil.ReadFile("mock-replies/" + filenameToUse)
if err != nil {
return `{"error":"unable to open mock file to send a real reply"}`, nil
}
return string(data), nil
}