Documentation ¶
Index ¶
- func StartAdmin(lookupHTTPAddr []string, httpAddrs string)
- type AddAdmin
- type AddConstumer
- type Admin
- type Drift
- func (d *Drift) AddChanelHandler(topic, channel string, jobHandler JobHandler)
- func (d *Drift) AddConsumer(payload AddConstumer) (data interface{}, err error)
- func (d *Drift) AddTopicHandler(topic string, jobHandler JobHandler)
- func (d *Drift) Publish(topic string, data interface{}) (resp interface{}, err error)
- func (d *Drift) SetLogger(l *log.Logger, lvl LogLevel)
- func (d *Drift) Start(port int)
- type JobHandler
- type KillConsumer
- type LogLevel
- type Publish
- type TopicData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartAdmin ¶
StartAdmin will start admin
Types ¶
type AddAdmin ¶
type AddAdmin struct { AdminUser []string `json:"user"` HTTPAddrs string `json:"http_address"` LookupHTTPAddr []string `json:"lookup_http_address"` NsqDTCPAddrs []string `json:"nsqd_tcp_address"` ACLHTTPHeader string `json:"acl_http_header"` NotificationHTTPEndpoint string `json:"notification_http_endpoint"` }
AddAdmin is the add admin request
type AddConstumer ¶
type AddConstumer struct { LookupHTTPAddr []string `json:"lookup_http_address"` NsqDTCPAddrs []string `json:"nsqd_tcp_address"` Topic []TopicData `json:"topic_detail"` MaxInFlight int `json:"max_in_flight"` StartAdmin bool `json:"start_admin"` }
AddConstumer is the request format of add consumer api
type Admin ¶
type Admin struct { Topic string `json:"topic"` Channel string `json:"channel"` Action string `json:"action"` }
Admin is the request format of admin api to permorm action. allowed actions are - create/empty/delete/pause/unpause
type Drift ¶
type Drift struct { Server aqua.RestServer // contains filtered or unexported fields }
Drift have the consumer/publisher model
func NewConsumer ¶
func NewConsumer(jobHandler JobHandler) *Drift
NewConsumer will create new consumer
Example ¶
New consumer created with handel to call by the consumer. This will start new server to receive request over HTTP
package main 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 main() { //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) }
Output:
func NewPub ¶
NewPub will create new publisher
Example ¶
new pub created to publish message to nsqd
msg := flag.String("msg", "Hi this is a test", "Message to broadcast") flag.Parse() nsqdTCPAddrs := []string{"127.0.0.1:4150"} d := drift.NewPub(nsqdTCPAddrs) topic := "elastic" if resp, err := d.Publish(topic, *msg); err == nil { fmt.Println(resp) } else { fmt.Println(err.Error()) }
Output:
func (*Drift) AddChanelHandler ¶
func (d *Drift) AddChanelHandler(topic, channel string, jobHandler JobHandler)
AddChanelHandler will add a new handler with the channel of given topic
func (*Drift) AddConsumer ¶
func (d *Drift) AddConsumer(payload AddConstumer) (data interface{}, err error)
AddConsumer will process add consumer request
func (*Drift) AddTopicHandler ¶
func (d *Drift) AddTopicHandler(topic string, jobHandler JobHandler)
AddTopicHandler will add a new handler with the given topic
type JobHandler ¶
type JobHandler func(value ...interface{}) error
JobHandler function which will be called
type KillConsumer ¶
type KillConsumer struct { Topic string `json:"topic"` Channel string `json:"channel"` Count int `json:"count"` }
KillConsumer is the request format of kill consumer api