修改infra除repository包

This commit is contained in:
2025-11-05 22:22:46 +08:00
parent 07d8c719ac
commit 97aea66f7c
13 changed files with 293 additions and 242 deletions

View File

@@ -1,12 +1,15 @@
package transport
import "time"
import (
"context"
"time"
)
// Communicator 用于其他设备通信
type Communicator interface {
// Send 用于发送一条单向数据(不等待回信)
// 成功时,它返回一个包含 MessageID 的 SendResult以便调用方追踪。
Send(address string, payload []byte) (*SendResult, error)
Send(ctx context.Context, address string, payload []byte) (*SendResult, error)
}
// SendResult 包含了 SendGo 方法成功执行后返回的结果。
@@ -27,8 +30,8 @@ type SendResult struct {
// Listener 用于监听其他设备发送过来的数据
type Listener interface {
// Listen 用于开始监听其他设备发送过来的数据
Listen() error
Listen(ctx context.Context) error
// Stop 用于停止监听
Stop() error
Stop(ctx context.Context) error
}