An open API service indexing awesome lists of open source software.

https://github.com/kercylan98/vivid-proto

Protocol Buffers Codec for Vivid Remoting — optional serialization for cross-node Actor messages.
https://github.com/kercylan98/vivid-proto

actor-model codec go golang protobuf protocol-buffers remoting serialization vivid

Last synced: about 1 month ago
JSON representation

Protocol Buffers Codec for Vivid Remoting — optional serialization for cross-node Actor messages.

Awesome Lists containing this project

README

          

[![Go Reference](https://pkg.go.dev/badge/github.com/kercylan98/vivid-proto.svg)](https://pkg.go.dev/github.com/kercylan98/vivid-proto)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Go Version](https://img.shields.io/badge/Go-1.25.1+-00ADD8?style=flat&logo=go)](https://golang.org)

**vivid-proto** 为 [Vivid](https://github.com/kercylan98/vivid) Actor 库提供基于 **Protocol Buffers** 的远程消息编解码器(Codec),用于 Remoting 跨节点通信时的消息序列化与反序列化。

## 特性

- **实现 vivid.Codec 接口**:可直接作为 `WithActorSystemCodec` 传入,与 Vivid Remoting 无缝集成
- **类型名 + 载荷**:通过包装消息(类型全名 + 二进制载荷)支持多 Proto 消息类型,无需为每种消息单独注册
- **依赖精简**:仅依赖 `github.com/kercylan98/vivid` 与 `google.golang.org/protobuf`

## 系统要求与安装

- **Go**:1.25.1+
- **安装**:

```bash
go get github.com/kercylan98/vivid-proto
```

## 使用方式

1. 在业务中定义 `.proto` 并生成 Go 代码(需在运行时被 `protoregistry.GlobalTypes` 注册,通常由 `protoc` 生成代码中的 `init` 完成)。
2. 创建 Codec 并传给 Vivid 的 ActorSystem:

```go
import (
"github.com/kercylan98/vivid"
"github.com/kercylan98/vivid-proto/pkg/codec"
"github.com/kercylan98/vivid/pkg/bootstrap"
)

c := codec.New()
system := bootstrap.NewActorSystem(
vivid.WithActorSystemRemoting("0.0.0.0:8080"),
vivid.WithActorSystemCodec(c),
)
```

跨节点传递的消息须为 `proto.Message`;本地可继续使用任意类型,仅经 Remoting 发送的消息会经此 Codec 编解码。完整示例见 [example](example/)。

## 与 Vivid 的关系

- **vivid**:[高性能、类型安全的 Go Actor 模型库](https://github.com/kercylan98/vivid),提供 Actor 系统、Remoting、监督策略等。
- **vivid-proto**:为 Vivid 提供可选的 Proto Codec 实现,用于 Remoting 消息序列化。未使用 Remoting 或采用其他 Codec/RegisterCustomMessage 时无需本库。

## 许可证

[MIT](LICENSE)