本文整理汇总了Golang中github.com/RichardKnop/machinery/v1/signatures.TaskSignature类的典型用法代码示例。如果您正苦于以下问题:Golang TaskSignature类的具体用法?Golang TaskSignature怎么用?Golang TaskSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskSignature类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Publish
// Publish places a new message on the default queue
func (amqpBroker *AMQPBroker) Publish(signature *signatures.TaskSignature) error {
conn, channel, _, err := open(amqpBroker.config)
if err != nil {
return err
}
defer close(channel, conn)
message, err := json.Marshal(signature)
if err != nil {
return fmt.Errorf("JSON Encode Message: %v", err)
}
signature.AdjustRoutingKey(
amqpBroker.config.ExchangeType,
amqpBroker.config.BindingKey,
amqpBroker.config.DefaultQueue,
)
return channel.Publish(
amqpBroker.config.Exchange, // exchange
signature.RoutingKey, // routing key
false, // mandatory
false, // immediate
amqp.Publishing{
ContentType: "application/json",
Body: message,
DeliveryMode: amqp.Persistent,
},
)
}
开发者ID:wmydz1,项目名称:machinery,代码行数:31,代码来源:amqp.go
示例2: NewChord
// NewChord creates Chord instance
func NewChord(group *Group, callback *signatures.TaskSignature) *Chord {
// Generate a UUID for the chord callback
callback.UUID = fmt.Sprintf("chord_%v", uuid.New())
// Add a chord callback to all tasks
for _, task := range group.Tasks {
task.ChordCallback = callback
}
return &Chord{Group: group, Callback: callback}
}
开发者ID:spinx,项目名称:machinery,代码行数:12,代码来源:workflow.go
示例3: Publish
// Publish places a new message on the default queue
func (amqpBroker *AMQPBroker) Publish(signature *signatures.TaskSignature) error {
conn, channel, _, confirmsChan, err := amqpBroker.open()
if err != nil {
return err
}
defer amqpBroker.close(channel, conn)
message, err := json.Marshal(signature)
if err != nil {
return fmt.Errorf("JSON Encode Message: %v", err)
}
signature.AdjustRoutingKey(
amqpBroker.config.ExchangeType,
amqpBroker.config.BindingKey,
amqpBroker.config.DefaultQueue,
)
if err := channel.Publish(
amqpBroker.config.Exchange, // exchange
signature.RoutingKey, // routing key
false, // mandatory
false, // immediate
amqp.Publishing{
ContentType: "application/json",
Body: message,
DeliveryMode: amqp.Persistent,
},
); err != nil {
return err
}
confirmed := <-confirmsChan
if confirmed.Ack {
return nil
}
return fmt.Errorf("Failed delivery of delivery tag: %v", confirmed.DeliveryTag)
}
开发者ID:spinx,项目名称:machinery,代码行数:41,代码来源:amqp.go
示例4: SendTask
// SendTask publishes a task to the default queue
func (server *Server) SendTask(signature *signatures.TaskSignature) (*backends.AsyncResult, error) {
// Auto generate a UUID if not set already
if signature.UUID == "" {
signature.UUID = uuid.New()
}
if err := server.broker.Publish(signature); err != nil {
return nil, fmt.Errorf("Publish Message: %v", err)
}
// Update task state to PENDING
if err := server.backend.SetStatePending(signature); err != nil {
return nil, fmt.Errorf("Set State Pending: %v", err)
}
return backends.NewAsyncResult(signature, server.backend), nil
}
开发者ID:ddmd2015,项目名称:machinery,代码行数:18,代码来源:server.go
示例5: SendTask
// SendTask publishes a task to the default queue
func (server *Server) SendTask(signature *signatures.TaskSignature) (*backends.AsyncResult, error) {
// Make sure result backend is defined
if server.backend == nil {
return nil, errors.New("Result backend required")
}
// Auto generate a UUID if not set already
if signature.UUID == "" {
signature.UUID = fmt.Sprintf("task_%v", uuid.New())
}
// Set initial task state to PENDING
if err := server.backend.SetStatePending(signature); err != nil {
return nil, fmt.Errorf("Set State Pending: %v", err)
}
if err := server.broker.Publish(signature); err != nil {
return nil, fmt.Errorf("Publish Message: %v", err)
}
return backends.NewAsyncResult(signature, server.backend), nil
}
开发者ID:wizard580,项目名称:machinery,代码行数:23,代码来源:server.go
注:本文中的github.com/RichardKnop/machinery/v1/signatures.TaskSignature类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论