當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Publisher.Connect方法代碼示例

本文整理匯總了Golang中github.com/elastic/beats/libbeat/publisher.Publisher.Connect方法的典型用法代碼示例。如果您正苦於以下問題:Golang Publisher.Connect方法的具體用法?Golang Publisher.Connect怎麽用?Golang Publisher.Connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/elastic/beats/libbeat/publisher.Publisher的用法示例。


在下文中一共展示了Publisher.Connect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewPublisher

func NewPublisher(pub *publisher.Publisher, hwm, bulkHWM int) *PacketbeatPublisher {
	return &PacketbeatPublisher{
		pub:    pub,
		client: pub.Connect(),
		done:   make(chan struct{}),
		trans:  make(chan common.MapStr, hwm),
		flows:  make(chan []common.MapStr, bulkHWM),
	}
}
開發者ID:radoondas,項目名稱:apachebeat,代碼行數:9,代碼來源:publish.go

示例2: NewPublisher

func NewPublisher(
	pub publisher.Publisher,
	hwm, bulkHWM int,
) (*PacketbeatPublisher, error) {
	topo, ok := pub.(TopologyProvider)
	if !ok {
		return nil, errors.New("Requires topology provider")
	}

	return &PacketbeatPublisher{
		pub:            pub,
		topo:           topo,
		geoLite:        topo.GeoLite(),
		ignoreOutgoing: topo.IgnoreOutgoing(),
		client:         pub.Connect(),
		done:           make(chan struct{}),
		trans:          make(chan common.MapStr, hwm),
		flows:          make(chan []common.MapStr, bulkHWM),
	}, nil
}
開發者ID:ChongFeng,項目名稱:beats,代碼行數:20,代碼來源:publish.go

示例3: newModuleWrappers

// newModuleWrappers creates new Modules and their associated MetricSets based
// on the given configuration. It constructs the supporting filters and
// publisher client and stores it all in a moduleWrapper.
func newModuleWrappers(
	modulesConfig []*common.Config,
	r *mb.Register,
	publisher *publisher.Publisher,
) ([]*moduleWrapper, error) {
	modules, err := mb.NewModules(modulesConfig, r)
	if err != nil {
		return nil, err
	}

	// Wrap the Modules and MetricSet's.
	var wrappers []*moduleWrapper
	var errs multierror.Errors
	for k, v := range modules {
		debugf("initializing Module type %s, %T=%+v", k.Name(), k, k)
		f, err := filter.New(k.Config().Filters)
		if err != nil {
			errs = append(errs, errors.Wrapf(err, "module %s", k.Name()))
			continue
		}

		mw := &moduleWrapper{
			Module:    k,
			filters:   f,
			pubClient: publisher.Connect(),
		}
		wrappers = append(wrappers, mw)

		msws := make([]*metricSetWrapper, 0, len(v))
		for _, ms := range v {
			debugf("initializing MetricSet type %s/%s, %T=%+v",
				ms.Module().Name(), ms.Name(), ms, ms)
			msw := &metricSetWrapper{
				MetricSet: ms,
				module:    mw,
				stats:     new(expvar.Map).Init(),
			}
			msws = append(msws, msw)

			// Initialize expvar stats for this MetricSet.
			fetches.Set(fmt.Sprintf("%s-%s", mw.Name(), msw.Name()), msw.stats)
			msw.stats.Add(successesKey, 0)
			msw.stats.Add(failuresKey, 0)
			msw.stats.Add(eventsKey, 0)
		}
		mw.metricSets = msws
	}

	return wrappers, errs.Err()
}
開發者ID:yan2jared,項目名稱:beats,代碼行數:53,代碼來源:module.go


注:本文中的github.com/elastic/beats/libbeat/publisher.Publisher.Connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。