202
// The request's token supplies schedID/attempt; the version comes from the started
203
// workflow task
204
>
identity := workflowTaskIdentity{schedID: schedID, attempt: attempt, version: c.startedWorkflowTaskIdentity().version}
context.go
205
>
// a buffer for a different workflow task is stale, clear it
206
>
if c.taskCompletionBuffer != nil && c.taskCompletionBuffer.identity != identity {
207
c.clearTaskCompletionBuffer()
208
}
209
>
if c.taskCompletionBuffer == nil {
context.go
210
>
c.taskCompletionBuffer = &TaskCompletionBuffer{
211
>
pages: make(map[int32][]*commandpb.Command),
212
>
identity: identity,
213
>
}
214
>
}
215
// Keep existing page if it is already buffered
216
>
if _, ok := c.taskCompletionBuffer.pages[request.GetPageNumber()]; ok {
context.go
217
return nil
218
}
219
220
>
pageBytes := taskCompletionPageBytes(request.Commands)
context.go
221
>
222
>
// Apply per-workflow task limit
223
>
nsName := c.MutableState.GetNamespaceEntry().Name().String()
224
>
perWorkflowLimitBytes := int64(c.config.WorkflowTaskCompletionBufferSizeLimit(nsName))
225
>
if perWorkflowLimitBytes > 0 && c.taskCompletionBuffer.totalSize+pageBytes > perWorkflowLimitBytes {
226
c.clearTaskCompletionBuffer()
227
return ErrTaskCompletionBufferSizeExceeded