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


Golang Message.StreamID方法代码示例

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


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

示例1: routeMessage

func (stream *Route) routeMessage(msg core.Message) {
	for i := 0; i < len(stream.routes); i++ {
		target := stream.routes[i]

		// Stream might require late binding
		if target.stream == nil {
			if core.StreamRegistry.WildcardProducersExist() {
				target.stream = core.StreamRegistry.GetStreamOrFallback(target.id)
			} else if target.stream = core.StreamRegistry.GetStream(target.id); target.stream == nil {
				// Remove without preserving order allows us to continue iterating
				lastIdx := len(stream.routes) - 1
				stream.routes[i] = stream.routes[lastIdx]
				stream.routes = stream.routes[:lastIdx]
				i--
				continue // ### continue, no route ###
			}
		}

		if target.id == stream.GetBoundStreamID() {
			stream.StreamBase.Route(msg, stream.GetBoundStreamID())
		} else {
			msg := msg // copy to allow streamId changes and multiple routes
			msg.StreamID = target.id
			target.stream.Enqueue(msg)
		}
	}
}
开发者ID:pombredanne,项目名称:gollum-1,代码行数:27,代码来源:route.go

示例2: route

func (cons *LoopBack) route(msg core.Message) {
	if streams, routeExists := cons.routes[msg.StreamID]; routeExists {
		for targetID, targetStream := range streams {
			msg.StreamID = targetID
			targetStream.Enqueue(msg)
		}
	} else {
		// Extend the cache
		targetStream := cons.addRoute(msg.StreamID, msg.StreamID)
		targetStream.Enqueue(msg)
	}
}
开发者ID:oopcode,项目名称:gollum,代码行数:12,代码来源:loopback.go


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