当前位置: 首页>>代码示例>>Golang>>正文


Golang Event.Payload方法代码示例

本文整理汇总了Golang中github.com/tideland/gocells/cells.Event.Payload方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.Payload方法的具体用法?Golang Event.Payload怎么用?Golang Event.Payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tideland/gocells/cells.Event的用法示例。


在下文中一共展示了Event.Payload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: newEventData

// newEventData returns the passed event as event data to collect.
func newEventData(event cells.Event) EventData {
	data := EventData{
		Topic:   event.Topic(),
		Payload: event.Payload(),
	}
	return data
}
开发者ID:tideland,项目名称:gocells,代码行数:8,代码来源:collector.go

示例2: ProcessEvent

// ProcessEvent reads, validates and emits a configuration.
func (b *configuratorBehavior) ProcessEvent(event cells.Event) error {
	switch event.Topic() {
	case ReadConfigurationTopic:
		// Read configuration
		filename, ok := event.Payload().GetString(ConfigurationFilenamePayload)
		if !ok {
			logger.Errorf("cannot read configuration without filename payload")
			return nil
		}
		logger.Infof("reading configuration from %q", filename)
		cfg, err := etc.ReadFile(filename)
		if err != nil {
			return errors.Annotate(err, ErrCannotReadConfiguration, errorMessages)
		}
		// If wanted then validate it.
		if b.validate != nil {
			err = b.validate(cfg)
			if err != nil {
				return errors.Annotate(err, ErrCannotValidateConfiguration, errorMessages)
			}
		}
		// All done, emit it.
		pvs := cells.PayloadValues{
			ConfigurationPayload: cfg,
		}
		b.cell.EmitNewContext(ConfigurationTopic, pvs, event.Context())
	}
	return nil
}
开发者ID:tideland,项目名称:gocells,代码行数:30,代码来源:configurator.go

示例3: payloadCents

// cents retrieves the cents out of the payload of an event.
func payloadCents(event cells.Event) int {
	cents, ok := event.Payload().Get(cells.DefaultPayload)
	if !ok {
		return -1
	}
	return cents.(int)
}
开发者ID:tideland,项目名称:gocells,代码行数:8,代码来源:fsm_test.go

示例4: ProcessEvent

// ProcessEvent calls a callback functions with the event data.
func (b *callbackBehavior) ProcessEvent(event cells.Event) error {
	for _, callbackFunc := range b.callbackFuncs {
		if err := callbackFunc(event.Topic(), event.Payload()); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:tideland,项目名称:gocells,代码行数:9,代码来源:callback.go

示例5: Configuration

// Configuration returns the configuration payload
// of the passed event or an empty configuration.
func Configuration(event cells.Event) etc.Etc {
	payload, ok := event.Payload().Get(ConfigurationPayload)
	if !ok {
		logger.Warningf("event does not contain configuration payload")
		cfg, _ := etc.ReadString("{etc}")
		return cfg
	}
	cfg, ok := payload.(etc.Etc)
	if !ok {
		logger.Warningf("configuration payload has illegal type")
		cfg, _ := etc.ReadString("{etc}")
		return cfg
	}
	return cfg
}
开发者ID:tideland,项目名称:gocells,代码行数:17,代码来源:configurator.go

示例6: ProcessEvent

func (b *emitBehavior) ProcessEvent(event cells.Event) error {
	return b.c.EmitNew(sleepTopic, event.Payload())
}
开发者ID:tideland,项目名称:gocells,代码行数:3,代码来源:behaviors_test.go


注:本文中的github.com/tideland/gocells/cells.Event.Payload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。