优化用户模型和模块租户检查逻辑,新增NATS消息配置和MongoDB缓存控制

This commit is contained in:
2026-01-21 16:33:37 +08:00
committed by 张斌
parent f0e6bdd37c
commit b303c1bfaa
16 changed files with 1954 additions and 497 deletions

View File

@@ -46,7 +46,12 @@ func TestNatsStreamOperations(t *testing.T) {
ctx := context.Background()
// 创建任务流
err := CreateTaskStream(ctx, "test_tasks", []string{"test.task.>"})
config := TaskStreamConfig{
StreamName: "test_tasks",
Subjects: []string{"test.task.>"},
//Subject: "test.task.process",
}
err := CreateTaskStream(ctx, config)
if err != nil {
t.Logf("创建任务流失败: %v", err)
}
@@ -79,7 +84,12 @@ func TestNatsConsumerOperations(t *testing.T) {
ctx := context.Background()
// 创建测试流
err := CreateTaskStream(ctx, "test_consumer", []string{"test.consumer.>"})
config := TaskStreamConfig{
StreamName: "test_consumer",
Subjects: []string{"test.consumer.>"},
//Subject: "test.consumer.process",
}
err := CreateTaskStream(ctx, config)
if err != nil {
t.Logf("创建流失败: %v", err)
}
@@ -119,22 +129,3 @@ func TestNatsConsumerOperations(t *testing.T) {
// 清理流
_ = DeleteStream(ctx, "test_consumer")
}
// TestNatsPublishRequest 测试发布和请求
func TestNatsPublishRequest(t *testing.T) {
ctx := context.Background()
// 发布消息
err := Publish(ctx, "test.publish", []byte("hello"))
if err != nil {
t.Logf("发布消息失败: %v", err)
}
// RPC 请求
response, err := CallRPC(ctx, "test.request", []byte("request"), 5*time.Second)
if err != nil {
t.Logf("RPC 请求失败: %v", err)
} else {
t.Logf("RPC 响应: %s", string(response))
}
}