Add LowCollector & rename Supervisor to Monitoring
[src/xds/xds-agent.git] / lib / aglafb / afb.go
1 /*
2  * Copyright (C) 2019 "IoT.bzh"
3  * Author Sebastien Douheret <sebastien@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package aglafb
19
20 import "fmt"
21
22 // AfbRequest Resquest field of a reply
23 type AfbRequest struct {
24         Status string `json:"status"`
25         Info   string `json:"info"`
26 }
27
28 // AfbReply Reply structure of XDS Monitoring Daemon
29 type AfbReply struct {
30         JType    string      `json:"jtype"`
31         Request  AfbRequest  `json:"request"`
32         Response interface{} `json:"response"`
33 }
34
35 func NewAfbReply() *AfbReply {
36         return &AfbReply{}
37 }
38
39 func (r *AfbReply) Success() bool {
40         return r.Request.Status == "success"
41 }
42
43 func (r *AfbReply) Failure() bool {
44         return !r.Success()
45 }
46
47 func (r *AfbReply) GetError() error {
48         return fmt.Errorf(r.Request.Info)
49 }
50
51 func (r *AfbReply) GetInfo() string {
52         return r.Request.Info
53 }