Skip to content

Commit 0edc3c8

Browse files
committed
Add Aeron transport stubs
1 parent 4570c2e commit 0edc3c8

File tree

10 files changed

+199
-1
lines changed

10 files changed

+199
-1
lines changed

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.20)
22
project(epoch_cpp VERSION 0.1.0 LANGUAGES CXX)
33

4-
add_library(epoch_cpp src/epoch.cpp src/engine.cpp src/actor_id.cpp)
4+
add_library(epoch_cpp src/epoch.cpp src/engine.cpp src/actor_id.cpp src/aeron_transport.cpp)
55

66
target_include_directories(epoch_cpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
77

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include "epoch/transport.h"
4+
5+
#include <string>
6+
7+
namespace epoch {
8+
9+
struct AeronConfig {
10+
std::string channel;
11+
std::int32_t stream_id;
12+
std::string aeron_directory;
13+
};
14+
15+
class AeronTransport final : public Transport {
16+
public:
17+
explicit AeronTransport(AeronConfig config);
18+
19+
void send(const Message &message) override;
20+
std::vector<Message> poll(std::size_t max) override;
21+
void close() override;
22+
23+
private:
24+
AeronConfig config_;
25+
bool closed_ = false;
26+
};
27+
28+
} // namespace epoch

cpp/src/aeron_transport.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "epoch/aeron_transport.h"
2+
3+
#include <stdexcept>
4+
5+
namespace epoch {
6+
7+
AeronTransport::AeronTransport(AeronConfig config) : config_(std::move(config)) {}
8+
9+
void AeronTransport::send(const Message &)
10+
{
11+
throw std::runtime_error("Aeron transport not linked");
12+
}
13+
14+
std::vector<Message> AeronTransport::poll(std::size_t)
15+
{
16+
throw std::runtime_error("Aeron transport not linked");
17+
}
18+
19+
void AeronTransport::close()
20+
{
21+
closed_ = true;
22+
}
23+
24+
} // namespace epoch

docs/guide/protocol.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
## Aeron 集成
3333
- 设计说明见:`docs/guide/transport-aeron.md`
3434

35+
## QoS 分级建议
36+
- `240-255`: 系统/运维命令(如诊断、状态查询)
37+
- `128-239`: 关键控制类消息
38+
- `1-127`: 普通业务消息
39+
- `0`: 默认
40+
3541
## 测试向量
3642
- 必须提供“输入明细 + 期望 stateHash”的测试向量
3743
- 所有语言实现都需复用该向量

dotnet/AeronTransport.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Epoch;
2+
3+
public sealed class AeronTransport : ITransport
4+
{
5+
public sealed record AeronConfig(string Channel, int StreamId, string AeronDirectory);
6+
7+
public AeronTransport(AeronConfig config)
8+
{
9+
Config = config;
10+
}
11+
12+
public AeronConfig Config { get; }
13+
14+
public void Send(Message message)
15+
{
16+
throw new NotSupportedException("Aeron transport not linked");
17+
}
18+
19+
public List<Message> Poll(int max)
20+
{
21+
throw new NotSupportedException("Aeron transport not linked");
22+
}
23+
24+
public void Close()
25+
{
26+
}
27+
}

go/aeron_transport.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package epoch
2+
3+
import "fmt"
4+
5+
type AeronConfig struct {
6+
Channel string
7+
StreamID int
8+
AeronDirectory string
9+
}
10+
11+
type AeronTransport struct {
12+
config AeronConfig
13+
}
14+
15+
func NewAeronTransport(config AeronConfig) *AeronTransport {
16+
return &AeronTransport{config: config}
17+
}
18+
19+
func (t *AeronTransport) Send(message Message) {
20+
panic(fmt.Errorf("Aeron transport not linked"))
21+
}
22+
23+
func (t *AeronTransport) Poll(max int) []Message {
24+
panic(fmt.Errorf("Aeron transport not linked"))
25+
}
26+
27+
func (t *AeronTransport) Close() {
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.epoch;
2+
3+
import java.util.List;
4+
5+
public final class AeronTransport implements Transport {
6+
public record AeronConfig(String channel, int streamId, String aeronDirectory) {
7+
}
8+
9+
private final AeronConfig config;
10+
11+
public AeronTransport(AeronConfig config) {
12+
this.config = config;
13+
}
14+
15+
@Override
16+
public void send(Engine.Message message) {
17+
throw new UnsupportedOperationException("Aeron transport not linked");
18+
}
19+
20+
@Override
21+
public List<Engine.Message> poll(int max) {
22+
throw new UnsupportedOperationException("Aeron transport not linked");
23+
}
24+
25+
@Override
26+
public void close() {
27+
// no-op for stub
28+
}
29+
30+
public AeronConfig config() {
31+
return config;
32+
}
33+
}

node/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,28 @@ class InMemoryTransport {
8181
}
8282
}
8383

84+
class AeronTransport {
85+
constructor(config) {
86+
this.config = config;
87+
}
88+
89+
send() {
90+
throw new Error("Aeron transport not linked");
91+
}
92+
93+
poll() {
94+
throw new Error("Aeron transport not linked");
95+
}
96+
97+
close() {}
98+
}
99+
84100
module.exports = {
85101
version,
86102
fnv1a64Hex,
87103
processMessages,
88104
InMemoryTransport,
105+
AeronTransport,
89106
defaultActorIdCodec: actorId.defaultActorIdCodec,
90107
encodeActorId: actorId.encodeActorId,
91108
decodeActorId: actorId.decodeActorId

python/epoch/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
default_actor_id_codec,
66
encode_actor_id,
77
)
8+
from .aeron_transport import AeronConfig, AeronTransport
89
from .engine import EpochResult, Message, fnv1a64_hex, process_messages
910
from .transport import InMemoryTransport, Transport
1011

@@ -21,6 +22,8 @@
2122
"process_messages",
2223
"Transport",
2324
"InMemoryTransport",
25+
"AeronConfig",
26+
"AeronTransport",
2427
]
2528

2629

python/epoch/aeron_transport.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from __future__ import annotations
2+
3+
from dataclasses import dataclass
4+
from typing import List
5+
6+
from .engine import Message
7+
from .transport import Transport
8+
9+
10+
@dataclass(frozen=True)
11+
class AeronConfig:
12+
channel: str
13+
stream_id: int
14+
aeron_directory: str
15+
16+
17+
class AeronTransport(Transport):
18+
def __init__(self, config: AeronConfig) -> None:
19+
self._config = config
20+
21+
@property
22+
def config(self) -> AeronConfig:
23+
return self._config
24+
25+
def send(self, message: Message) -> None:
26+
raise NotImplementedError("Aeron transport not linked")
27+
28+
def poll(self, max_items: int) -> List[Message]:
29+
raise NotImplementedError("Aeron transport not linked")
30+
31+
def close(self) -> None:
32+
return None

0 commit comments

Comments
 (0)