Add Run control event stream

This commit is contained in:
npc0-hue
2026-08-26 23:06:06 +08:00
parent 6369a8099a
commit 55a5d6de80
10 changed files with 274 additions and 3 deletions
+22
View File
@@ -57,6 +57,20 @@ type RunControlHeartbeatResponse struct {
ServerTime time.Time `json:"serverTime"`
}
type RunControlStreamRequest struct {
RunEndpointID string `json:"runEndpointId"`
SessionToken string `json:"sessionToken"`
LastEventSeq uint64 `json:"lastEventSeq,omitempty"`
}
type RunControlEventResponse struct {
RunEndpointID string `json:"runEndpointId"`
Sequence uint64 `json:"sequence"`
Type string `json:"type"`
ServerTime time.Time `json:"serverTime"`
RetrySeconds int `json:"retrySeconds,omitempty"`
}
type RunLifecycleReportRequest struct {
RunEndpointID string `json:"runEndpointId"`
SessionToken string `json:"sessionToken"`
@@ -115,6 +129,10 @@ func (request RunControlHeartbeatRequest) ToDomain() domain.RunControlHeartbeat
}
}
func (request RunControlStreamRequest) ToDomain() domain.RunControlStreamRequest {
return domain.RunControlStreamRequest{RunEndpointID: request.RunEndpointID, SessionToken: request.SessionToken, LastEventSeq: request.LastEventSeq}
}
func (request RunLifecycleReportRequest) ToDomain() domain.RunLifecycleReport {
return domain.RunLifecycleReport{
RunEndpointID: request.RunEndpointID,
@@ -155,6 +173,10 @@ func RunControlHeartbeatFromDomain(result domain.RunControlHeartbeatResult) RunC
}
}
func RunControlEventFromDomain(event domain.RunControlEvent) RunControlEventResponse {
return RunControlEventResponse{RunEndpointID: event.RunEndpointID, Sequence: event.Sequence, Type: event.Type, ServerTime: event.ServerTime, RetrySeconds: event.RetrySeconds}
}
func RunLifecycleReportFromDomain(result domain.RunLifecycleReportResult) RunLifecycleReportResponse {
result = domain.CopyRunLifecycleReportResult(result)
return RunLifecycleReportResponse{Accepted: result.Accepted, RunEndpointID: result.RunEndpointID, ServerInstanceID: result.ServerInstanceID, ProjectedState: result.ProjectedState, ServerTime: result.ServerTime}