appendEventsExample 追加事件
(ctx context.Context, service *mysql.Service, sessionID string)
| 90 | |
| 91 | // appendEventsExample 追加事件 |
| 92 | func appendEventsExample(ctx context.Context, service *mysql.Service, sessionID string) { |
| 93 | event := &session.Event{ |
| 94 | ID: "evt-" + generateID(), |
| 95 | Timestamp: time.Now(), |
| 96 | InvocationID: "inv-mysql-001", |
| 97 | AgentID: "agent-mysql-support", |
| 98 | Branch: "root", |
| 99 | Author: "user", |
| 100 | Content: types.Message{ |
| 101 | Role: types.RoleUser, |
| 102 | Content: "测试 MySQL JSON 列", |
| 103 | }, |
| 104 | Actions: session.EventActions{ |
| 105 | StateDelta: map[string]any{ |
| 106 | "session:db_type": "mysql", |
| 107 | "session:version": "8.0+", |
| 108 | }, |
| 109 | }, |
| 110 | } |
| 111 | |
| 112 | if err := service.AppendEvent(ctx, sessionID, event); err != nil { |
| 113 | log.Fatalf("Failed to append event: %v", err) |
| 114 | } |
| 115 | |
| 116 | fmt.Println("✅ Event appended with JSON columns") |
| 117 | } |
| 118 | |
| 119 | // jsonColumnExample 演示 JSON 列的优势 |
| 120 | func jsonColumnExample(ctx context.Context, service *mysql.Service, sessionID string) { |
no test coverage detected