func (c ChanClient) PublishEvents(events []common.MapStr, opts ...ClientOption) bool {
	for _, event := range events {
		c.Channel <- event
	}
	return true
}
PublishEvents publishes all event on the configured channel. Options will be ignored.
Always returns true.
package publisher
import (
	"expvar"
	"github.com/elastic/beats/libbeat/common"
	"github.com/elastic/beats/libbeat/logp"
	"github.com/elastic/beats/libbeat/outputs"
)
var (
	publishedEvents = expvar.NewInt("libbeatPublishedEvents")
)
type Client interface {
	PublishEvent(event common.MapStr, opts ...ClientOption) bool
	PublishEvents(events []common.MapStr, opts ...ClientOption) bool
}
type ChanClient struct {
	Channel chan common.MapStr
}
type ExtChanClient struct {
	Channel chan PublishMessage
}
type PublishMessage struct {
	Context Context
	Events  []common.MapStr
}
type client struct {
	publisher *PublisherType
	beatMeta common.MapStr
	tags     []string
}
type ClientOption func(option Context) Context
func Guaranteed(o Context) Context {
	o.Guaranteed = true
	return o
}
func Sync(o Context) Context {
	o.Sync = true
	return o
}
func Signal(signaler outputs.Signaler) ClientOption {
	return func(ctx Context) Context {
		if ctx.Signal == nil {
			ctx.Signal = signaler
		} else {
			ctx.Signal = outputs.NewCompositeSignaler(ctx.Signal, signaler)
		}
		return ctx
	}
}
func newClient(pub *PublisherType) *client {
	return &client{
		publisher: pub,
		beatMeta: common.MapStr{
			"name":     pub.name,
			"hostname": pub.hostname,
		},
		tags: pub.tags,
	}
}
func (c *client) PublishEvent(event common.MapStr, opts ...ClientOption) bool {
	c.annotateEvent(event)
	ctx, client := c.getClient(opts)
	publishedEvents.Add(1)
	return client.PublishEvent(ctx, event)
}
func (c *client) PublishEvents(events []common.MapStr, opts ...ClientOption) bool {
	for _, event := range events {
		c.annotateEvent(event)
	}
	ctx, client := c.getClient(opts)
	publishedEvents.Add(int64(len(events)))
	return client.PublishEvents(ctx, events)
}
func (c *client) annotateEvent(event common.MapStr) {
	if _, ok := event["beat"]; ok {
		beatTemp := event["beat"].(common.MapStr)
		if _, ok := beatTemp["index"]; ok {
			c.beatMeta["index"] = beatTemp["index"]
		}
	}
	event["beat"] = c.beatMeta
	if len(c.tags) > 0 {
		event["tags"] = c.tags
	}
	if logp.IsDebug("publish") {
		PrintPublishEvent(event)
	}
}
func (c *client) getClient(opts []ClientOption) (Context, eventPublisher) {
	ctx := makeContext(opts)
	if ctx.Sync {
		return ctx, c.publisher.syncPublisher.client()
	}
	return ctx, c.publisher.asyncPublisher.client()
}
func (c ChanClient) PublishEvent(event common.MapStr, opts ...ClientOption) bool {
	c.Channel <- event
	return true
}