Return created ingress info from io service (#4787)

The stream key is randomly generated for each request. Return
exsiting record if the `ingressID` already exists on retry.
This commit is contained in:
cnderrauber
2026-08-25 09:03:09 +08:00
committed by GitHub
parent 906764691c
commit f7954d5747
+7 -4
View File
@@ -140,13 +140,14 @@ func (s *IngressService) CreateIngressWithUrl(ctx context.Context, urlStr string
urlStr = urlObj.String() urlStr = urlObj.String()
} }
reqID := RequestID(ctx)
var sk string var sk string
if req.InputType != livekit.IngressInput_URL_INPUT { if req.InputType != livekit.IngressInput_URL_INPUT {
sk = guid.New("") sk = guid.New("")
} }
info := &livekit.IngressInfo{ info := &livekit.IngressInfo{
IngressId: guid.New(utils.IngressPrefix), IngressId: DeterministicID(utils.IngressPrefix, reqID),
Name: req.Name, Name: req.Name,
StreamKey: sk, StreamKey: sk,
Url: urlStr, Url: urlStr,
@@ -192,11 +193,13 @@ func (s *IngressService) CreateIngressWithUrl(ctx context.Context, urlStr string
} }
// The Ingress instance will create the ingress object when handling the URL pull ingress // The Ingress instance will create the ingress object when handling the URL pull ingress
} else { } else {
// TODO-jie: ingress retry idempotency: generate ingress key by request-id, and return the ingress object from CreateIngress. var resp *rpc.CreateIngressResponse
_, err = s.io.CreateIngress(ctx, info) resp, err = s.io.CreateIngress(ctx, info)
switch err { switch err {
case nil: case nil:
break if resp.GetInfo() != nil {
info = resp.GetInfo()
}
case ingress.ErrIngressOutOfDate: case ingress.ErrIngressOutOfDate:
// Error returned if the ingress was already created by the ingress service // Error returned if the ingress was already created by the ingress service
err = nil err = nil