diff --git a/parser.go b/parser.go index 171848b..eec3d8d 100644 --- a/parser.go +++ b/parser.go @@ -144,13 +144,11 @@ func (p *Parser) ConfigQueue(yamlpath string) { panic(err) } - log.Println(string(data)) err = yaml.Unmarshal(data, p.que) if err != nil { panic(err) } - log.Println(p.que) if err := p.que.Connect(); err != nil { panic(err) } diff --git a/parser_test.go b/parser_test.go index 21f8a3a..c0c65b9 100644 --- a/parser_test.go +++ b/parser_test.go @@ -37,9 +37,9 @@ func (tt *Toutiao) ToDoParser(adstring string) (string, error) { func TestParserToutiao(t *testing.T) { tt := Toutiao{} - tt.ConfigLogDB("logdb.yaml") + // tt.ConfigLogDB("logdb.yaml") tt.ConfigQueue("queue.yaml") - ADParserServer(&tt) + // ADParserServer(&tt) t.Error("") } diff --git a/queue.go b/queue.go index 82de7f9..7d1491c 100644 --- a/queue.go +++ b/queue.go @@ -11,9 +11,9 @@ import ( // Queue Youmi的队列 type Queue struct { - url string `yaml:"url"` - exchange string `yaml:"exchange"` - routekey string `yaml:"routekey"` + Url string `yaml:"url"` + Exchange string `yaml:"exchange"` + Routekey string `yaml:"routekey"` mutex sync.Mutex conn *amqp.Connection @@ -23,7 +23,7 @@ type Queue struct { // NewQueue youmi queue队列 mq func NewQueue(url string, exchange, routekey string) *Queue { - que := Queue{url: url, exchange: exchange, routekey: routekey} + que := Queue{Url: url, Exchange: exchange, Routekey: routekey} que.contentType = "application/json" if err := que.Connect(); err != nil { @@ -45,7 +45,7 @@ func (que *Queue) Connect() error { que.mutex.Lock() defer que.mutex.Unlock() - conn, err := amqp.Dial(que.url) + conn, err := amqp.Dial(que.Url) if err != nil { return err } @@ -68,7 +68,7 @@ func (que *Queue) Push(data []byte) error { panic(err) } } - return ch.Publish(que.exchange, que.routekey, false, false, amqp.Publishing{ + return ch.Publish(que.Exchange, que.Routekey, false, false, amqp.Publishing{ DeliveryMode: amqp.Persistent, Timestamp: time.Now(), ContentType: que.contentType, diff --git a/queue.yaml b/queue.yaml index f816aeb..787b0a0 100644 --- a/queue.yaml +++ b/queue.yaml @@ -1,4 +1,4 @@ -# url: "amqp://spider:spider@172.16.6.109:5672/test_adspider" url: "amqp://test_aso:guest@10.10.10.31:5672/test_spider_go" exchange: "ad_process" -routekey: "CN" \ No newline at end of file +routekey: "CN" +# url: "amqp://spider:spider@172.16.6.109:5672/test_adspider" \ No newline at end of file