-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsumer_example_test.go
40 lines (31 loc) · 1014 Bytes
/
consumer_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package drift
import (
"fmt"
"github.com/mayur-tolexo/drift"
)
func printIT(value ...interface{}) error {
fmt.Println("In 1st Print", value)
return nil
}
func printIT2(value ...interface{}) error {
fmt.Println("In 2nd Print", value)
return nil
}
func printIT3(value ...interface{}) error {
fmt.Println("In 3rd Print", value)
return nil
}
// New consumer created with handel to call by the consumer.
// This will start new server to receive request over HTTP
func ExampleNewConsumer() {
//Default handler is printIT
d := drift.NewConsumer(printIT)
// This will map a new handeler with specified topic's channel
d.AddChanelHandler("elastic", "v6.2", printIT2)
// This will map a new handeler with all channels of the specified topic.
// If a channelHandler is already mapped with any channel of the specified topic then that handler will be called
// and in rest of the channel this handler will be called.
d.AddTopicHandler("elastic", printIT3)
//port assign here is 1500
d.Start(1500)
}