events

package
v0.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asynchronous

func Asynchronous[I, T comparable](
	actuator AsynchronousActuator,
	handler AsynchronousHandler,
	callback AsynchronousCallbackHandler,
) nexus.Event[I, T]

Asynchronous 创建一个异步消息实例,并指定相应的处理器。 该函数接收以下参数:

  • broker:消息所属的 Broker 实例。
  • actuator:异步消息的执行器,负责执行异步消息的逻辑,当该参数为空时,将会使用默认的 go func()。
  • handler:异步消息的逻辑处理器,用于执行实际的异步消息处理逻辑,可选参数。
  • callback:异步消息的回调处理器,处理消息处理完成后的回调操作,可选参数。
  • afterHandler:异步消息执行完成后的处理器,用于进行后续的处理操作,可选参数。

该函数除了 handler,其他所有处理器均为同步执行

返回值为一个实现了 Event 接口的异步消息实例。

func Synchronous

func Synchronous[I, T comparable](handler SynchronousHandler) nexus.Event[I, T]

Types

type AsynchronousActuator

type AsynchronousActuator func(context.Context, func(context.Context)) // 负责执行异步消息的执行器

type AsynchronousCallbackHandler

type AsynchronousCallbackHandler func(context.Context, error) // 异步消息回调处理器

type AsynchronousHandler

type AsynchronousHandler func(context.Context) error // 异步消息逻辑处理器

type SynchronousHandler

type SynchronousHandler func(context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL