remove result channel
This commit is contained in:
parent
c22eae51c6
commit
0f0ca89ac4
|
@ -50,9 +50,9 @@ func TestSend(t *testing.T) {
|
|||
}))
|
||||
defer ts.Close()
|
||||
for i := 0; i < 10; i++ {
|
||||
e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Message: "Test"})
|
||||
e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Version: "Test"})
|
||||
Send(e)
|
||||
t.Log(e.GetResult())
|
||||
// t.Log(e.GetResult())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"loafle.com/commons/communicate/events"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type communicator struct {
|
||||
|
@ -27,8 +26,15 @@ func (c *communicator) start() {
|
|||
go func(event *events.Event) {
|
||||
m := event.Data.(events.URLMaker)
|
||||
data, _ := json.Marshal(event)
|
||||
r, _ := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(data))
|
||||
e.Result <- events.Result{Message: strconv.Itoa(r.StatusCode)}
|
||||
res, err := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(data))
|
||||
|
||||
// todo timeout,error
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
if res.StatusCode != 200 && res.StatusCode != 201 {
|
||||
|
||||
}
|
||||
}(e)
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -30,12 +30,12 @@ type Event struct {
|
|||
Time Timestamp
|
||||
EventType string
|
||||
Data interface{}
|
||||
Result chan Result `json:"-"`
|
||||
//Result chan Result `json:"-"`
|
||||
}
|
||||
|
||||
func (e *Event) GetResult() Result {
|
||||
return <-e.Result
|
||||
}
|
||||
//func (e *Event) GetResult() Result {
|
||||
// return <-e.Result
|
||||
//}
|
||||
|
||||
func NewEvent(dataType string, data interface{}) *Event {
|
||||
return &Event{
|
||||
|
@ -43,6 +43,5 @@ func NewEvent(dataType string, data interface{}) *Event {
|
|||
Time: Now(),
|
||||
EventType: dataType,
|
||||
Data: data,
|
||||
Result: make(chan Result),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user