fmt
This commit is contained in:
@@ -7,26 +7,25 @@ import (
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
)
|
||||
|
||||
type ProbeService struct {
|
||||
}
|
||||
|
||||
type Probe struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Status *meta.MetaProbeStatus `json:"status,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
LastPollingDate timestamp.Timestamp `json:"lastPollingDate,omitempty"`
|
||||
NextPollingDate timestamp.Timestamp `json:"nextPollingDate,omitempty"`
|
||||
Domain *domain.Domain `json:"domain,omitempty"`
|
||||
ProbeKey string `json:"probeKey,omitempty"`
|
||||
EncryptionKey string `json:"encryptionKey,omitempty"`
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Status *meta.MetaProbeStatus `json:"status,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
LastPollingDate timestamp.Timestamp `json:"lastPollingDate,omitempty"`
|
||||
NextPollingDate timestamp.Timestamp `json:"nextPollingDate,omitempty"`
|
||||
Domain *domain.Domain `json:"domain,omitempty"`
|
||||
ProbeKey string `json:"probeKey,omitempty"`
|
||||
EncryptionKey string `json:"encryptionKey,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
func NewProbeService() *ProbeService {
|
||||
return &ProbeService{}
|
||||
}
|
||||
@@ -34,10 +33,9 @@ func NewProbeService() *ProbeService {
|
||||
func NewProbe(probeKey string, encryptionKey string) *Probe {
|
||||
|
||||
na := &Probe{
|
||||
Status:meta.NewMetaProbeStatus(meta.PROBE_STATUS_INITIAL),
|
||||
ProbeKey:probeKey,
|
||||
EncryptionKey:encryptionKey,
|
||||
|
||||
Status: meta.NewMetaProbeStatus(meta.PROBE_STATUS_INITIAL),
|
||||
ProbeKey: probeKey,
|
||||
EncryptionKey: encryptionKey,
|
||||
}
|
||||
return na
|
||||
}
|
||||
@@ -73,4 +71,4 @@ func (as *ProbeService) ReadByProbeKey(probeKey string) (string, error) {
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package probe
|
||||
|
||||
import (
|
||||
|
||||
"testing"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/keystore"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/keystore"
|
||||
)
|
||||
|
||||
func TestSaveProbe(t *testing.T) {
|
||||
@@ -17,7 +14,7 @@ func TestSaveProbe(t *testing.T) {
|
||||
enks, _ := ks.CreateKey()
|
||||
|
||||
ppp := NewProbe(pks, enks)
|
||||
ppp.Domain = &domain.Domain{Id:"1"}
|
||||
ppp.Domain = &domain.Domain{Id: "1"}
|
||||
as := NewProbeService()
|
||||
|
||||
res, err := as.Regist(ppp)
|
||||
@@ -30,12 +27,11 @@ func TestSaveProbe(t *testing.T) {
|
||||
func TestListProbe(t *testing.T) {
|
||||
as := NewProbeService()
|
||||
|
||||
d := &domain.Domain{Id:"1"}
|
||||
|
||||
d := &domain.Domain{Id: "1"}
|
||||
|
||||
if res, err := as.ReadAllByDomain(d); err != nil {
|
||||
t.Fatal(err)
|
||||
}else {
|
||||
} else {
|
||||
t.Log(res)
|
||||
}
|
||||
|
||||
@@ -55,7 +51,6 @@ func TestReadProbeKey(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestDDDD(t *testing.T) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,44 +2,43 @@ package probe
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
)
|
||||
|
||||
type ProbeTask struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
MetaProbeTaskType *meta.MetaProbeTaskType `json:"metaProbeTaskType,omitempty"`
|
||||
Probe *Probe `json:"probe,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
SendDate timestamp.Timestamp `json:"sendDate,omitempty"`
|
||||
StartDate timestamp.Timestamp `json:"startDate,omitempty"`
|
||||
EndDate timestamp.Timestamp `json:"startDate,omitempty"`
|
||||
Succeed bool `json:"succeed,omitempty"`
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
MetaProbeTaskType *meta.MetaProbeTaskType `json:"metaProbeTaskType,omitempty"`
|
||||
Probe *Probe `json:"probe,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
SendDate timestamp.Timestamp `json:"sendDate,omitempty"`
|
||||
StartDate timestamp.Timestamp `json:"startDate,omitempty"`
|
||||
EndDate timestamp.Timestamp `json:"startDate,omitempty"`
|
||||
Succeed bool `json:"succeed,omitempty"`
|
||||
}
|
||||
|
||||
func NewProbeTask(types *meta.MetaProbeTaskType, data string, p *Probe) *ProbeTask {
|
||||
|
||||
return &ProbeTask{
|
||||
MetaProbeTaskType:types,
|
||||
Data:data,
|
||||
Probe:p,
|
||||
MetaProbeTaskType: types,
|
||||
Data: data,
|
||||
Probe: p,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type ProbeTaskService struct {
|
||||
|
||||
}
|
||||
|
||||
func NewProbeTaskService() *ProbeTaskService{
|
||||
func NewProbeTaskService() *ProbeTaskService {
|
||||
return &ProbeTaskService{}
|
||||
}
|
||||
|
||||
func(pts* ProbeTaskService)Regist(pt *ProbeTask) (string, error) {
|
||||
func (pts *ProbeTaskService) Regist(pt *ProbeTask) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("probeTask","save", pt, utils.MODEL_PROBE_TASK)
|
||||
out, err := utils.InvokeDBByModel("probeTask", "save", pt, utils.MODEL_PROBE_TASK)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -48,9 +47,9 @@ func(pts* ProbeTaskService)Regist(pt *ProbeTask) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func(pts* ProbeTaskService)ReadAllByProbe(p *Probe) (string, error) {
|
||||
func (pts *ProbeTaskService) ReadAllByProbe(p *Probe) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("probeTask","findAllByProbe", p, utils.MODEL_PROBE)
|
||||
out, err := utils.InvokeDBByModel("probeTask", "findAllByProbe", p, utils.MODEL_PROBE)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package probe
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
@@ -17,14 +17,13 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
out, err := pts.Regist(pt)
|
||||
|
||||
if err != nil{
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Log(out)
|
||||
}
|
||||
|
||||
|
||||
func TestListByProbe(t *testing.T) {
|
||||
|
||||
p := &Probe{}
|
||||
@@ -40,6 +39,4 @@ func TestListByProbe(t *testing.T) {
|
||||
|
||||
t.Log(out)
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user