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

Function createSessionExample

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

createSessionExample 创建 Session 示例

(ctx context.Context, service *postgres.Service)

Source from the content-addressed store, hash-verified

75
76// createSessionExample 创建 Session 示例
77func createSessionExample(ctx context.Context, service *postgres.Service) *session.SessionData {
78 req := &session.CreateRequest{
79 AppName: "demo-app",
80 UserID: "user-001",
81 AgentID: "agent-customer-support",
82 }
83
84 sess, err := service.Create(ctx, req)
85 if err != nil {
86 log.Fatalf("Failed to create session: %v", err)
87 }
88
89 fmt.Printf("✅ Created session: %s\n", sess.ID)
90 fmt.Printf(" App: %s, User: %s, Agent: %s\n", sess.AppName, sess.UserID, sess.AgentID)
91 return sess
92}
93
94// appendEventsExample 追加事件示例
95func appendEventsExample(ctx context.Context, service *postgres.Service, sessionID string) {

Callers 1

mainFunction · 0.70

Calls 2

PrintfMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected