MCPcopy Create free account
hub / github.com/astercloud/aster / appendEventsExample

Function appendEventsExample

examples/session-mysql/main.go:92–117  ·  view source on GitHub ↗

appendEventsExample 追加事件

(ctx context.Context, service *mysql.Service, sessionID string)

Source from the content-addressed store, hash-verified

90
91// appendEventsExample 追加事件
92func 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 列的优势
120func jsonColumnExample(ctx context.Context, service *mysql.Service, sessionID string) {

Callers 1

mainFunction · 0.70

Calls 2

generateIDFunction · 0.70
AppendEventMethod · 0.65

Tested by

no test coverage detected