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