소스 검색

更新日志和修改变量

lxg 3 년 전
부모
커밋
6b2af04c1b
2개의 변경된 파일10개의 추가작업 그리고 8개의 파일을 삭제
  1. 5 3
      broker/inprocess.go
  2. 5 5
      broker/subscriber/http.go

+ 5 - 3
broker/inprocess.go

@@ -3,6 +3,7 @@ package broker
 import (
 	"context"
 	"fmt"
+	"git.nspix.com/golang/micro/log"
 	"runtime"
 	"sync"
 )
@@ -15,7 +16,6 @@ type InProcBus struct {
 	subscribers      map[string]Subscriber
 }
 
-
 func (bus *InProcBus) worker() {
 	for {
 		select {
@@ -67,7 +67,9 @@ func (bus *InProcBus) DispatchCtx(ctx context.Context, e *Event) (err error) {
 	defer bus.subscriberLocker.RUnlock()
 	for _, sub := range bus.subscribers {
 		if sub.HasTopic(e.Name) {
-			err = sub.Process(ctx, e)
+			if err = sub.Process(ctx, e); err != nil {
+				log.Warnf("subscriber %s process event %s error: %s", sub.ID(), e.Name, err.Error())
+			}
 		}
 	}
 	releaseEvent(e)
@@ -109,4 +111,4 @@ func NewInPrcBus(ctx context.Context) *InProcBus {
 		eventChan:   make(chan *Event, 100),
 		subscribers: make(map[string]Subscriber),
 	}
-}
+}

+ 5 - 5
broker/subscriber/http.go

@@ -14,7 +14,7 @@ import (
 )
 
 var (
-	MaxHttpTimeout = time.Second * 10  //最大的HTTP处理超时时间
+	MaxHttpTimeout = time.Second * 10 //最大的HTTP处理超时时间
 )
 
 var (
@@ -24,10 +24,10 @@ var (
 )
 
 type Http struct {
-	Id     string
-	Url    string
-	Topics []string
-	Format string
+	Id     string   `json:"id"`
+	Url    string   `json:"url"`
+	Topics []string `json:"topics"`
+	Format string   `json:"format"`
 }
 
 func (sub *Http) ID() string {