Atlas › Test

TestSearchAttributes_RoundTripThroughCloseTransaction

Exact test identity: go.temporal.io/server/chasm/lib/scheduler/TestSearchAttributes_RoundTripThroughCloseTransaction

Package
go.temporal.io/server/chasm/lib/scheduler
Suite / test hierarchy
TestSearchAttributes_RoundTripThroughCloseTransaction
Test
TestSearchAttributes_RoundTripThroughCloseTransaction
Introduced at
TestSearchAttributes_RoundTripThroughCloseTransaction Frontier kind: Test frontier
Covered ranges
1173
Covered lines
5170
Covered files
169

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/chasm/tree.go 816 covered LOC · 273 ranges

Open complete file

301 logger log.Logger,
302 metricsHandler metrics.Handler,
303 > ) *Node { tree.go
304 > root := newTreeHelper(registry, timeSource, backend, pathEncoder, logger, metricsHandler)
305 >
306 > // If serializedNodes is empty, it means that this new tree.
307 > // Initialize empty serializedNode.
308 > root.initSerializedNode(fieldTypeComponent)
309 > // Default to Workflow archetype as empty tree is created for workflow as well.
310 > root.serializedNode.Metadata.GetComponentAttributes().TypeId = WorkflowArchetypeID
311 > // Although both value and serializedNode.Data are nil, they are considered NOT synced
312 > // because value has no type and serializedNode does.
313 > // deserialize method should set value when called.
314 > root.setValueState(valueStateNeedDeserialize)
315 > return root
316 > }
317
318 func newTreeHelper(
323 logger log.Logger,
324 metricsHandler metrics.Handler,
325 > ) *Node { tree.go
326 > base := &nodeBase{
327 > registry: registry,
328 > timeSource: timeSource,
329 > backend: backend,
330 > pathEncoder: pathEncoder,
331 > logger: logger,
332 > metricsHandler: metricsHandler,
333 >
334 > mutation: NodesMutation{
335 > UpdatedNodes: make(map[string]*persistencespb.ChasmNode),
336 > DeletedNodes: make(map[string]struct{}),
337 > },
338 > systemMutation: NodesMutation{
339 > UpdatedNodes: make(map[string]*persistencespb.ChasmNode),
340 > DeletedNodes: make(map[string]struct{}),
341 > },
342 > newTasks: make(map[any][]taskWithAttributes),
343 > immediatePureTasks: make(map[any][]taskWithAttributes),
344 > pendingRequestLinks: make(map[any]map[string][]*commonpb.Link),
345 > pendingUserMetadata: make(map[any]*sdkpb.UserMetadata),
346 > valueToNode: make(map[any]*Node),
347 > taskValueCache: make(map[*commonpb.DataBlob]reflect.Value),
348 > needsPointerResolution: false,
349 > }
350 >
351 > return newNode(base, nil, "")
352 > }
353
354 func newTreeInitSearchAttributesAndMemo(
377 }
378
379 > func searchAttributeKeyValuesToMap(saSlice []SearchAttributeKeyValue) map[string]VisibilityValue { tree.go
380 > result := make(map[string]VisibilityValue, len(saSlice))
381 > for _, sa := range saSlice {
382 > result[sa.Field] = sa.Value
383 > }
384 > return result
385 }
386
387 func (n *Node) SetRootComponent(
388 rootComponent RootComponent,
389 > ) error { tree.go
390 > root := n.root()
391 > root.setValue(rootComponent)
392 > root.setValueState(valueStateNeedSyncStructure)
393 > if componentID, ok := n.registry.ComponentIDFor(rootComponent); ok {
394 > root.serializedNode.GetMetadata().GetComponentAttributes().TypeId = componentID
395 > }
396 > return root.syncSubComponents()
397 }
398
400 // If the node is a component or data node, the index from node value to node (valueToNode)
401 // is also updated.
402 > func (n *Node) setValue(value any) { tree.go
403 > if !n.isComponent() && !n.isData() {
404 n.value = value
405 return
406 }
407
408 > if n.value != nil { tree.go
409 > delete(n.valueToNode, n.value) tree.go
410 > }
411
412 > n.value = value tree.go
413 >
414 > if value != nil {
415 > n.valueToNode[value] = n
416 > }
417 }
418
419 > func (n *Node) setValueState(state valueState) { tree.go
420 > n.valueState = state
421 > if state >= valueStateNeedSerialize {
422 > n.markSubtreeDirty() tree.go
423 > }
424 }
425
429 // markSubtreeDirty marks this node and its entire lineage (ancestors and descendants)
430 // as dirty so that CloseTransaction knows to validate their tasks.
431 > func (n *Node) markSubtreeDirty() { tree.go
432 > // Propagate upward to ancestors.
433 > for cur := n; cur != nil && !cur.subtreeIsDirty; cur = cur.parent {
434 > cur.subtreeIsDirty = true
435 > }
436 // Propagate downward to descendants.
437 > for _, desc := range n.andAllChildren() { tree.go
438 > desc.subtreeIsDirty = true
439 > }
440 }
441
458 chasmContext Context,
459 ref ComponentRef,
460 > ) (Component, error) { tree.go
461 > // Archetype is already validated before this method is called.
462 > // (when the mutable state is loaded, in chasm engine implementation)
463 >
464 > node, ok := n.findNode(ref.componentPath)
465 > if !ok {
466 return nil, errComponentNotFound
467 }
468
469 > if ref.componentInitialVT != nil && transitionhistory.Compare( tree.go
470 > ref.componentInitialVT,
471 > node.serializedNode.Metadata.InitialVersionedTransition,
472 > ) != 0 {
473 return nil, errComponentNotFound
474 }
475
476 > validationContext := NewContext(chasmContext.goContext(), node) tree.go
477 > if err := node.prepareComponentValue(validationContext); err != nil {
478 return nil, err
479 }
480
481 > componentValue, ok := node.value.(Component) tree.go
482 > if !ok {
483 return nil, softassert.UnexpectedInternalErr(
484 n.logger,
487 }
488
489 > if err := node.validateAccess(validationContext, false); err != nil { tree.go
490 return nil, err
491 }
492
493 > if ref.validationFn != nil { tree.go
494 if err := ref.validationFn(node.root().backend, validationContext, componentValue, node.registry); err != nil {
495 return nil, err
498
499 // prepare component value again using incoming context to mark node as dirty if needed.
500 > if err := node.prepareComponentValue(chasmContext); err != nil { tree.go
501 return nil, err
502 }
503 > return componentValue, nil tree.go
504 }
505
517 // Note: engine mutations on paused components are still accepted (checkPaused=false),
518 // per the current requirement.
519 > func (n *Node) validateAccess(ctx Context, checkPaused bool) error { tree.go
520 > intent := operationIntentFromContext(ctx.goContext())
521 > if intent != OperationIntentProgress {
522 > // Read-only operations are always allowed. tree.go
523 > return nil
524 > }
525
526 // Detached nodes skip ancestor validation entirely.
527 > if n.isDetached() { tree.go
528 > return nil tree.go
529 > }
530
531 > if n.parent != nil { tree.go
532 > if err := n.parent.validateAccessHelper(ctx, checkPaused); err != nil { tree.go
533 return err
534 }
537 // validateAccessHelper traverses ancestors but never checks n itself.
538 // For task validation we must also check whether n is paused.
539 > if checkPaused && n.isComponent() { tree.go
540 > if err := n.prepareComponentValue(ctx); err != nil { tree.go
541 return err
542 }
543 > componentValue, _ := n.value.(Component) //nolint:revive // unchecked-type-assertion tree.go
544 > if componentValue.LifecycleState(ctx).IsPaused() {
545 return errAccessCheckFailed
546 }
547 }
548
549 > return nil tree.go
550 }
551
553 // node's lifecycle state AND its ancestors recursively.
554 // Do not call this method directly, call validateAccess instead.
555 > func (n *Node) validateAccessHelper(ctx Context, checkPaused bool) error { tree.go
556 > // Check ancestors first (if not detached).
557 > if !n.isDetached() && n.parent != nil {
558 if err := n.parent.validateAccessHelper(ctx, checkPaused); err != nil {
559 return err
562
563 // Only Component nodes need to be validated.
564 > if !n.isComponent() { tree.go
565 return nil
566 }
567
568 // Hydrate the component so we can access its LifecycleState.
569 > if err := n.prepareComponentValue(ctx); err != nil { tree.go
570 return err
571 }
572 > componentValue, _ := n.value.(Component) //nolint:revive // unchecked-type-assertion tree.go
573 >
574 > lifecycleState := componentValue.LifecycleState(ctx)
575 > if lifecycleState.IsClosed() {
576 return errAccessCheckFailed
577 }
578
579 > if checkPaused && lifecycleState.IsPaused() { tree.go
580 return errAccessCheckFailed
581 }
582
583 > if n.terminated { tree.go
584 // Terminated nodes can never be written to.
585 // This handles the case where root is terminated in the current transaction.
589 // terminated field check above is in memory only, so handle the case where root is terminated (closed)
590 // in a previous transaction and we have a mutable state reload which clears the field.
591 > if n.parent == nil && n.backend.GetExecutionState().State == enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED { tree.go
592 return errAccessCheckFailed
593 }
594
595 > return nil tree.go
596 }
597
598 func (n *Node) prepareComponentValue(
599 chasmContext Context,
600 > ) error { tree.go
601 > if n.valueState == valueStateNeedDeserialize {
602 metadata := n.serializedNode.Metadata
603 componentAttr := metadata.GetComponentAttributes()
624 // For now, we assume if a node is accessed with a MutableContext,
625 // its value will be mutated and no longer in sync with the serializedNode.
626 > _, componentCanBeMutated := chasmContext.(MutableContext) tree.go
627 > if componentCanBeMutated {
628 > n.setValueState(valueStateNeedSyncStructure) tree.go
629 > }
630
631 > return nil tree.go
632 }
633
680 }
681
682 > func (n *Node) isComponent() bool { tree.go
683 > return n.serializedNode.GetMetadata().GetComponentAttributes() != nil
684 > }
685
686 > func (n *Node) isData() bool { tree.go
687 > return n.serializedNode.GetMetadata().GetDataAttributes() != nil
688 > }
689
690 > func (n *Node) isMap() bool { tree.go
691 > return n.serializedNode.GetMetadata().GetCollectionAttributes() != nil
692 > }
693
694 > func (n *Node) isDetached() bool { tree.go
695 > componentAttr := n.serializedNode.GetMetadata().GetComponentAttributes()
696 > if componentAttr == nil {
697 return false
698 }
699 > componentTypeID := componentAttr.GetTypeId() tree.go
700 > if componentTypeID == CallbackComponentID ||
701 > componentTypeID == visibilityComponentTypeID {
702 > // For backward compatibility purpose, we need to special handle callback and visibility components, tree.go
703 > // which are implemented before detached component is properly supported by the framework.
704 > return true
705 > }
706 > return componentAttr.GetDetached() tree.go
707 }
708
709 > func (n *Node) fieldType() fieldType { tree.go
710 > if n.serializedNode.GetMetadata().GetComponentAttributes() != nil {
711 > return fieldTypeComponent tree.go
712 > }
713
714 > if n.serializedNode.GetMetadata().GetDataAttributes() != nil { tree.go
715 > return fieldTypeData tree.go
716 > }
717
718 if n.serializedNode.GetMetadata().GetPointerAttributes() != nil {
729 }
730
731 > func (n *Node) valueFields() iter.Seq[fieldInfo] { tree.go
732 > return fieldsOf(reflect.ValueOf(n.value))
733 > }
734
735 > func assertStructPointer(t reflect.Type) error { tree.go
736 > if t == nil {
737 return nil
738 }
739
740 > if t.Kind() != reflect.Pointer || t.Elem().Kind() != reflect.Struct { tree.go
741 return serviceerror.NewInternalf("only pointer to struct is supported for tree node value: got %s", t.String())
742 }
743 > return nil tree.go
744 }
745
746 > func (n *Node) initSerializedNode(ft fieldType) { tree.go
747 > switch ft {
748 > case fieldTypeData: tree.go
749 > n.serializedNode = &persistencespb.ChasmNode{
750 > Metadata: &persistencespb.ChasmNodeMetadata{
751 > InitialVersionedTransition: &persistencespb.VersionedTransition{
752 > TransitionCount: n.backend.NextTransitionCount(),
753 > NamespaceFailoverVersion: n.backend.GetCurrentVersion(),
754 > },
755 > Attributes: &persistencespb.ChasmNodeMetadata_DataAttributes{
756 > DataAttributes: &persistencespb.ChasmDataAttributes{},
757 > },
758 > },
759 > }
760 > case fieldTypeComponent: tree.go
761 > n.serializedNode = &persistencespb.ChasmNode{
762 > Metadata: &persistencespb.ChasmNodeMetadata{
763 > InitialVersionedTransition: &persistencespb.VersionedTransition{
764 > TransitionCount: n.backend.NextTransitionCount(),
765 > NamespaceFailoverVersion: n.backend.GetCurrentVersion(),
766 > },
767 > Attributes: &persistencespb.ChasmNodeMetadata_ComponentAttributes{
768 > ComponentAttributes: &persistencespb.ChasmComponentAttributes{},
769 > },
770 > },
771 > }
772 case fieldTypePointer, fieldTypeDeferredPointer:
773 // A deferred pointer will be resolved to a regular pointer before persistence.
827 // effects that must be persisted regardless of whether data bytes changed:
828 // new tasks scheduled on this node, or lifecycle termination.
829 > func (n *Node) hasNewTransactionSideEffects() bool { tree.go
830 > return len(n.newTasks[n.value]) > 0 || n.terminated
831 > }
832
833 // serialize sets or updates serializedValue field of the node n with serialized value.
834 // It sets node's valueState to valueStateSynced and updates LastUpdateVersionedTransition.
835 > func (n *Node) serialize() error { tree.go
836 > switch n.serializedNode.GetMetadata().GetAttributes().(type) {
837 > case *persistencespb.ChasmNodeMetadata_ComponentAttributes: tree.go
838 > return n.serializeComponentNode()
839 > case *persistencespb.ChasmNodeMetadata_DataAttributes: tree.go
840 > return n.serializeDataNode()
841 case *persistencespb.ChasmNodeMetadata_CollectionAttributes:
842 return n.serializeCollectionNode()
852 // LastUpdateVersionedTransition, the skip-if-clean revert logic in
853 // closeTransactionSerializeNodes must be updated accordingly.
854 > func (n *Node) serializeComponentNode() error { tree.go
855 > for field := range n.valueFields() {
856 > if field.err != nil {
857 return field.err
858 }
859
860 > if field.kind != fieldKindData { tree.go
861 > continue tree.go
862 }
863
864 > var blob *commonpb.DataBlob tree.go
865 > if !field.val.IsNil() {
866 > var err error tree.go
867 > if blob, err = encodeChasmBlob(field.val.Interface().(proto.Message)); err != nil {
868 return err
869 }
870 }
871
872 > n.serializedNode.Data = blob tree.go
873 >
874 > if n.serializedNode.GetMetadata().GetLastUpdateVersionedTransition() == nil {
875 > rc, ok := n.registry.componentFor(n.value) tree.go
876 > if !ok {
877 return softassert.UnexpectedInternalErr(
878 n.logger,
881 }
882 // TypeId mismatch on a brand new node indicates node reassignment.
883 > existingTypeID := n.serializedNode.GetMetadata().GetComponentAttributes().GetTypeId() tree.go
884 > if existingTypeID != 0 && existingTypeID != rc.componentID {
885 return softassert.UnexpectedInternalErr(
886 n.logger,
889 )
890 }
891 > n.serializedNode.GetMetadata().GetComponentAttributes().TypeId = rc.componentID tree.go
892 }
893
894 > n.updateLastUpdateVersionedTransition() tree.go
895 > n.setValueState(valueStateSynced)
896
897 // continue to iterate over fields to validate that there is only one proto field in the component.
898 }
899 > return nil tree.go
900 }
901
915 //
916 // nolint:revive,cognitive-complexity
917 > func (n *Node) syncSubComponents() error { tree.go
918 > if n.valueState < valueStateNeedSyncStructure {
919 > for _, childNode := range n.children { tree.go
920 > err := childNode.syncSubComponents() tree.go
921 > if err != nil {
922 return err
923 }
924 }
925 > return nil tree.go
926 }
927
928 > childrenToKeep := make(map[string]struct{}) tree.go
929 > for field := range n.valueFields() {
930 > if field.err != nil {
931 return field.err
932 }
933
934 > switch field.kind { tree.go
935 case fieldKindUnspecified:
936 softassert.Fail(n.logger,
937 "field.kind can be unspecified only if err is not nil, and there is a check for it above")
938 > case fieldKindData: tree.go
939 // Nothing to sync.
940 > case fieldKindSubField: tree.go
941 > keepChild, updatedFieldV, err := n.syncSubField(field.val, field.name)
942 > if err != nil {
943 return err
944 }
945 > if updatedFieldV.IsValid() { tree.go
946 > field.val.Set(updatedFieldV) tree.go
947 > }
948 > if keepChild { tree.go
949 > childrenToKeep[field.name] = struct{}{} tree.go
950 > }
951 > case fieldKindParentPtr: tree.go
952 > internalField := field.val.FieldByName(parentPtrInternalFieldName)
953 > internal, ok := internalField.Interface().(parentPtrInternal)
954 > if !ok {
955 return softassert.UnexpectedInternalErr(
956 n.logger,
958 fmt.Errorf("node %s, actual type: %T", n.nodeName, internalField.Interface()))
959 }
960 > if internal.currentNode == nil || internal.currentNode != n { tree.go
961 > internal.currentNode = n tree.go
962 > internalField.Set(reflect.ValueOf(internal))
963 > }
964 > case fieldKindSubMap: tree.go
965 > // Validate map type before doing anything with it.
966 > if !field.val.IsNil() && field.val.Kind() != reflect.Map {
967 return softassert.UnexpectedInternalErr(
968 n.logger,
971 }
972
973 > if field.val.IsNil() || len(field.val.MapKeys()) == 0 { tree.go
974 > // nil or empty map: skip without creating a collection node.
975 > // Any existing collection node will be removed by deleteChildren below.
976 > continue
977 }
978
1020 }
1021
1022 > err := n.deleteChildren(childrenToKeep) tree.go
1023 > n.setValueState(valueStateNeedSerialize)
1024 >
1025 > return err
1026 }
1027
1135 updatedFieldV reflect.Value,
1136 err error,
1137 > ) { tree.go
1138 > internalV := fieldV.FieldByName(internalFieldName)
1139 > //nolint:revive // Internal field is guaranteed to be of type fieldInternal.
1140 > internal := internalV.Interface().(fieldInternal)
1141 > if internal.isEmpty() {
1142 > // Internal is empty only when Field was explicitly set to NewEmptyField[T] which is a way to clear its value. tree.go
1143 > // In this case, return keepNode=false and this node (and all it children) will be added to DeletedNodes map.
1144 > return
1145 > }
1146
1147 > fieldValue := internal.value() tree.go
1148 > if internal.node == nil && fieldValue != nil {
1149 > fieldType := internal.fieldType() tree.go
1150 >
1151 > // Field is not empty but tree node is not set. It means this is a new field, and a node must be created.
1152 > childNode := newNode(n.nodeBase, n, fieldN)
1153 > childNode.initSerializedNode(fieldType)
1154 > childNode.setValueState(valueStateNeedSerialize)
1155 >
1156 > // set node value after validation
1157 > switch fieldType {
1158 > case fieldTypeComponent: tree.go
1159 > if err = assertStructPointer(reflect.TypeOf(fieldValue)); err != nil {
1160 return
1161 }
1162
1163 > childNode.setValueState(valueStateNeedSyncStructure) tree.go
1164 >
1165 > // Set detached flag from field option or component type registration.
1166 > componentAttr := childNode.serializedNode.GetMetadata().GetComponentAttributes()
1167 > componentAttr.Detached = internal.detached
1168 > if !componentAttr.Detached {
1169 > if rc, ok := n.registry.componentFor(fieldValue); ok {
1170 > componentAttr.Detached = rc.IsDetached()
1171 > }
1172 }
1173 > case fieldTypeData: tree.go
1174 > if err = assertStructPointer(reflect.TypeOf(fieldValue)); err != nil {
1175 return
1176 }
1193 return
1194 }
1195 > childNode.setValue(fieldValue) tree.go
1196 >
1197 > n.children[fieldN] = childNode
1198 > internal.node = childNode
1199 >
1200 > updatedFieldV = reflect.New(fieldV.Type()).Elem()
1201 > updatedFieldV.FieldByName(internalFieldName).Set(reflect.ValueOf(internal))
1202 }
1203
1204 > if internal.fieldType() == fieldTypeComponent && internal.value() != nil { tree.go
1205 > err = internal.node.syncSubComponents() tree.go
1206 > if err != nil {
1207 return
1208 }
1209 }
1210
1211 > return true, updatedFieldV, nil tree.go
1212 }
1213
1214 func (n *Node) deleteChildren(
1215 childrenToKeep map[string]struct{},
1216 > ) error { tree.go
1217 > for childName, childNode := range n.children {
1218 > if _, childToKeep := childrenToKeep[childName]; !childToKeep { tree.go
1219 if err := childNode.delete(false); err != nil {
1220 return err
1222 }
1223 }
1224 > return nil tree.go
1225 }
1226
1229 // LastUpdateVersionedTransition, the skip-if-clean revert logic in
1230 // closeTransactionSerializeNodes must be updated accordingly.
1231 > func (n *Node) serializeDataNode() error { tree.go
1232 > protoValue, ok := n.value.(proto.Message)
1233 > if !ok {
1234 return serviceerror.NewInternal("only support proto.Message as chasm data")
1235 }
1236
1237 > var blob *commonpb.DataBlob tree.go
1238 > if protoValue != nil {
1239 > var err error
1240 > if blob, err = encodeChasmBlob(protoValue); err != nil {
1241 return err
1242 }
1243 }
1244 > n.serializedNode.Data = blob tree.go
1245 > n.updateLastUpdateVersionedTransition()
1246 > n.setValueState(valueStateSynced)
1247 >
1248 > return nil
1249 }
1250
1277 }
1278
1279 > func (n *Node) updateLastUpdateVersionedTransition() { tree.go
1280 > if n.serializedNode.GetMetadata().GetLastUpdateVersionedTransition() == nil {
1281 > n.serializedNode.GetMetadata().LastUpdateVersionedTransition = &persistencespb.VersionedTransition{} tree.go
1282 > }
1283 > n.serializedNode.GetMetadata().GetLastUpdateVersionedTransition().TransitionCount = n.backend.NextTransitionCount() tree.go
1284 > n.serializedNode.GetMetadata().GetLastUpdateVersionedTransition().NamespaceFailoverVersion = n.backend.GetCurrentVersion()
1285 }
1286
1560 // reference a component that was never registered as a node are dropped and
1561 // logged at warn level to surface caller misuse.
1562 > func (n *Node) closeTransactionApplyPendingComponentMetadata() error { tree.go
1563 > if len(n.pendingRequestLinks) == 0 && len(n.pendingUserMetadata) == 0 {
1564 > return nil
1565 > }
1566 for _, node := range n.andAllChildren() {
1567 if !node.applyPendingComponentMetadata() {
1663 func (n *Node) Now(
1664 _ Component,
1665 > ) time.Time { tree.go
1666 > // TODO: Now() could be different for components after we support Pause for CHASM components.
1667 > return n.timeSource.Now()
1668 > }
1669
1670 // AddTask implements the CHASM MutableContext interface
1673 taskAttributes TaskAttributes,
1674 task any,
1675 > ) { tree.go
1676 > rt, ok := n.registry.taskFor(task)
1677 > if ok && rt.isPureTask && taskAttributes.IsImmediate() {
1678 > // Those tasks will be executed in the current transaction. tree.go
1679 > n.immediatePureTasks[component] = append(n.immediatePureTasks[component], taskWithAttributes{
1680 > task: task,
1681 > attributes: taskAttributes,
1682 > })
1683 > return
1684 > }
1685
1686 > n.newTasks[component] = append(n.newTasks[component], taskWithAttributes{ tree.go
1687 > task: task,
1688 > attributes: taskAttributes,
1689 > })
1690 }
1691
1692 // CloseTransaction is used by MutableState to close the transaction and
1693 // track changes made in the current transaction.
1694 > func (n *Node) CloseTransaction() (NodesMutation, error) { tree.go
1695 > defer n.cleanupTransaction()
1696 >
1697 > if err := n.executeImmediatePureTasks(); err != nil {
1698 return NodesMutation{}, err
1699 }
1700
1701 > if err := n.syncSubComponents(); err != nil { tree.go
1702 return NodesMutation{}, err
1703 }
1704
1705 > if n.needsPointerResolution { tree.go
1706 if err := n.resolveDeferredPointers(); err != nil {
1707 return NodesMutation{}, err
1709 }
1710
1711 > nextVersionedTransition := &persistencespb.VersionedTransition{ tree.go
1712 > NamespaceFailoverVersion: n.backend.GetCurrentVersion(),
1713 > TransitionCount: n.backend.NextTransitionCount(),
1714 > }
1715 >
1716 > immutableContext := NewContext(context.TODO(), n)
1717 > rootLifecycleChanged, err := n.closeTransactionHandleRootLifecycleChange(immutableContext)
1718 > if err != nil {
1719 return NodesMutation{}, err
1720 }
1721
1722 > if n.subtreeIsDirty { tree.go
1723 > if err := n.closeTransactionForceUpdateVisibility(immutableContext, rootLifecycleChanged); err != nil { tree.go
1724 return NodesMutation{}, err
1725 }
1726 }
1727
1728 > if err := n.closeTransactionSerializeNodes(); err != nil { tree.go
1729 return NodesMutation{}, err
1730 }
1731
1732 > if err := n.closeTransactionUpdateComponentTasks(nextVersionedTransition); err != nil { tree.go
1733 return NodesMutation{}, err
1734 }
1735
1736 > if err := n.closeTransactionApplyPendingComponentMetadata(); err != nil { tree.go
1737 return NodesMutation{}, err
1738 }
1739
1740 // Both user & system data mutation need to be returned and persisted.
1741 > maps.Copy(n.mutation.UpdatedNodes, n.systemMutation.UpdatedNodes) tree.go
1742 > maps.Copy(n.mutation.DeletedNodes, n.systemMutation.DeletedNodes)
1743 >
1744 > return n.mutation, nil
1745 }
1746
1747 > func (n *Node) executeImmediatePureTasks() error { tree.go
1748 >
1749 > // We must sync structure before running any tasks here because,
1750 > // those tasks might be for a newly created component which doesn't even have a node yet.
1751 > // And we want to make sure we only run tasks for components that are still part of the tree.
1752 > syncStructure := true
1753 > var err error
1754 >
1755 > for len(n.immediatePureTasks) != 0 {
1756 > // Create a map in case more immediate pure tasks get tree.go
1757 > // added while existing ones are executed.
1758 > immediatePureTasks := n.immediatePureTasks
1759 > n.immediatePureTasks = make(map[any][]taskWithAttributes)
1760 >
1761 > for component, pureTasks := range immediatePureTasks {
1762 > for _, task := range pureTasks {
1763 > if syncStructure {
1764 > if err := n.syncSubComponents(); err != nil {
1765 return err
1766 }
1772 // 2. Previous pure task for the node deleted the node itself via a (parent) pointer.
1773 // This is also why this check is done in the inner for loop.
1774 > taskNode, ok := n.valueToNode[component] tree.go
1775 > if !ok {
1776 break
1777 }
1778
1779 // Only syncStructure on next iteration if task is executed (the first return value).
1780 > syncStructure, err = taskNode.ExecutePureTask(context.Background(), task.attributes, task.task) tree.go
1781 > if err != nil {
1782 return err
1783 }
1786 }
1787
1788 > return nil tree.go
1789 }
1790
1791 func (n *Node) closeTransactionHandleRootLifecycleChange(
1792 immutableContext Context,
1793 > ) (bool, error) { tree.go
1794 > if n.backend.IsWorkflow() {
1795 // Workflow manages its lifecycle directly in mutable state.
1796 return false, nil
1797 }
1798
1799 > if n.valueState != valueStateNeedSerialize { tree.go
1800 return false, nil
1801 }
1802
1803 > if n.backend.GetExecutionState().State == enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED { tree.go
1804 // Already in completed state, no need to update lifecycle state.
1805 return false, nil
1806 }
1807
1808 > if n.terminated { tree.go
1809 return n.backend.UpdateWorkflowStateStatus(
1810 enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
1813 }
1814
1815 > rootComponent, err := n.Component(immutableContext, ComponentRef{}) tree.go
1816 > if err != nil {
1817 return false, err
1818 }
1819 > lifecycleState := rootComponent.LifecycleState(immutableContext) tree.go
1820 >
1821 > var newState enumsspb.WorkflowExecutionState
1822 > var newStatus enumspb.WorkflowExecutionStatus
1823 > switch lifecycleState {
1824 > case LifecycleStateRunning, LifecycleStatePaused:
1825 > // Paused is an OPEN state; the execution remains RUNNING from the persistence perspective.
1826 > newState = enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING
1827 > newStatus = enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING
1828 case LifecycleStateCompleted:
1829 newState = enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED
1839 }
1840
1841 > return n.backend.UpdateWorkflowStateStatus(newState, newStatus) tree.go
1842 }
1843
1845 immutableContext Context,
1846 rootLifecycleChanged bool,
1847 > ) error { tree.go
1848 > if n.deleteAfterClose {
1849 return nil
1850 }
1851
1852 > if !rootLifecycleChanged && tree.go
1853 > n.backend.GetExecutionState().State == enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED {
1854 return nil
1855 }
1856
1857 > needUpdate := rootLifecycleChanged tree.go
1858 >
1859 > rootComponent, err := n.Component(immutableContext, ComponentRef{})
1860 > if err != nil {
1861 return err
1862 }
1863
1864 > saProvider, ok := rootComponent.(VisibilitySearchAttributesProvider) tree.go
1865 > if ok {
1866 > saSlice := saProvider.SearchAttributes(immutableContext) tree.go
1867 > newSA := searchAttributeKeyValuesToMap(saSlice)
1868 > if !maps.EqualFunc(n.currentSA, newSA, isVisibilityValueEqual) {
1869 > needUpdate = true tree.go
1870 > }
1871 > n.currentSA = newSA tree.go
1872 }
1873
1874 > memoProvider, ok := rootComponent.(VisibilityMemoProvider) tree.go
1875 > if ok {
1876 > newMemo := memoProvider.Memo(immutableContext) tree.go
1877 > if !proto.Equal(n.currentMemo, newMemo) {
1878 > needUpdate = true tree.go
1879 > }
1880 > n.currentMemo = proto.Clone(newMemo) tree.go
1881 }
1882
1883 > if !needUpdate { tree.go
1884 return nil
1885 }
1886
1887 > var visibilityNode *Node tree.go
1888 > for _, child := range n.children {
1889 > if !child.isComponent() { tree.go
1890 > continue tree.go
1891 }
1892
1893 > if child.valueState == valueStateNeedSerialize { tree.go
1894 > if rc, ok := n.registry.componentFor(child.value); ok && rc.fqType() == visibilityComponentType { tree.go
1895 > visibilityNode = child tree.go
1896 > break
1897 }
1898 > } else if child.serializedNode.Metadata.GetComponentAttributes().TypeId == visibilityComponentTypeID { tree.go
1899 > visibilityNode = child tree.go
1900 > break
1901 }
1902 }
1903
1904 > if visibilityNode == nil { tree.go
1905 return nil
1906 }
1907
1908 > visComponent, err := visibilityNode.Component(immutableContext, ComponentRef{}) tree.go
1909 > if err != nil {
1910 return err
1911 }
1912
1913 > visibility, ok := visComponent.(*Visibility) tree.go
1914 > if !ok {
1915 return softassert.UnexpectedInternalErr(
1916 n.logger,
1924 // invalidates all previous logical tasks at the end of the transaction, and only one physical task
1925 // will be created in the visibility queue.
1926 > mutableContext := NewMutableContext(context.TODO(), n) tree.go
1927 > visibility.generateTask(mutableContext)
1928 > visibilityNode.setValueState(valueStateNeedSerialize)
1929 >
1930 > // We don't need to sync tree structure here for the visiblity node because we only generated a task without
1931 > // changing any component fields.
1932 > return nil
1933 }
1934
1935 > func (n *Node) closeTransactionSerializeNodes() error { tree.go
1936 > for nodePath, node := range n.andAllChildren() {
1937 > if node.valueState > valueStateNeedSerialize {
1938 return serviceerror.NewInternalf("invalid valueState for serializing: %v", node.valueState)
1939 }
1940
1941 > if node.valueState < valueStateNeedSerialize { tree.go
1942 > continue tree.go
1943 }
1944
1945 > encodedPath, err := node.getEncodedPath() tree.go
1946 > if err != nil {
1947 return err
1948 }
1952 // prevData captures the pre-serialize blob pointer; serialize() allocates a new
1953 // blob, leaving prevData pointing at the original for comparison.
1954 > prevVersionedTransition := common.CloneProto( tree.go
1955 > node.serializedNode.GetMetadata().GetLastUpdateVersionedTransition(),
1956 > )
1957 > skipIfClean := (node.isComponent() || node.isData() || node.isMap()) &&
1958 > prevVersionedTransition != nil &&
1959 > !node.hasNewTransactionSideEffects()
1960 > var prevData *commonpb.DataBlob
1961 > if skipIfClean {
1962 > prevData = node.serializedNode.Data tree.go
1963 > }
1964
1965 > if err := node.serialize(); err != nil { tree.go
1966 return err
1967 }
1968
1969 // Data bytes unchanged: revert the versioned transition bump and skip persistence.
1970 > if skipIfClean && bytes.Equal(prevData.GetData(), node.serializedNode.Data.GetData()) { tree.go
1971 node.serializedNode.GetMetadata().LastUpdateVersionedTransition = prevVersionedTransition
1972 continue
1973 }
1974
1975 > if componentAttr := node.serializedNode.GetMetadata().GetComponentAttributes(); componentAttr != nil && tree.go
1976 > componentAttr.TypeId == visibilityComponentTypeID &&
1977 > len(nodePath) != 1 {
1978 return softassert.UnexpectedInternalErr(
1979 n.logger,
1982 }
1983
1984 > n.mutation.UpdatedNodes[encodedPath] = node.serializedNode tree.go
1985 > // DeletedNodes map is populated when syncing tree structure. However, since we may sync tree structure
1986 > // multiple times in one transaction, if node at the same path was previously deleted, have structure synced,
1987 > // then get re-created, the same encoded path will exists in both UpdatedNodes and DeletedNodes maps.
1988 > //
1989 > // serializeNode only happens once at the end of a transaction, and here we know the node at this encoded path exists,
1990 > // remove it from the DeletedNodes map.
1991 > delete(n.mutation.DeletedNodes, encodedPath)
1992 }
1993
1994 > return nil tree.go
1995 }
1996
1997 func (n *Node) closeTransactionUpdateComponentTasks(
1998 nextVersionedTransition *persistencespb.VersionedTransition,
1999 > ) error { tree.go
2000 > taskOffset := int64(1)
2001 > taskValidationContext := NewContext(newContextWithOperationIntent(context.Background(), OperationIntentProgress), n)
2002 >
2003 > archetypeID := n.ArchetypeID()
2004 >
2005 > var firstPureTask *persistencespb.ChasmComponentAttributes_Task
2006 > var firstPureTaskNode *Node
2007 >
2008 > for nodePath, node := range n.andAllChildren() {
2009 > // no-op if node is not a component
2010 > componentAttr := node.serializedNode.Metadata.GetComponentAttributes()
2011 > if componentAttr == nil {
2012 > continue tree.go
2013 }
2014
2021 // markSubtreeDirty propagates to both ancestors and descendants at mutation time,
2022 // so we skip validation only for nodes with no dirty node anywhere in their lineage.
2023 > if node.subtreeIsDirty { tree.go
2024 > // Ensure this node's component value is hydrated before cleaning up tasks. tree.go
2025 > if err := node.prepareComponentValue(taskValidationContext); err != nil {
2026 return err
2027 }
2028
2029 > cleanedUp, err := node.closeTransactionCleanupInvalidTasks(taskValidationContext) tree.go
2030 > if err != nil {
2031 return err
2032 }
2033
2034 > if cleanedUp { tree.go
2035 > // add the current node to UpdatedNodes map if it's not already there tree.go
2036 > encodedPath, err := node.getEncodedPath()
2037 > if err != nil {
2038 return err
2039 }
2040 > if _, exists := n.mutation.UpdatedNodes[encodedPath]; !exists { tree.go
2041 // Mark the node as updated so changes will get replicated.
2042 node.updateLastUpdateVersionedTransition()
2054 // This method is called after the closeTransactionSerializeNodes which sets valueState
2055 // to valueStateSynced.
2056 > if transitionhistory.Compare( tree.go
2057 > node.serializedNode.GetMetadata().LastUpdateVersionedTransition,
2058 > nextVersionedTransition,
2059 > ) == 0 && node.valueState != valueStateNeedDeserialize {
2060 > if err := node.closeTransactionHandleNewTasks( tree.go
2061 > nextVersionedTransition,
2062 > taskValidationContext,
2063 > &taskOffset,
2064 > ); err != nil {
2065 return err
2066 }
2067 }
2068
2069 > sideEffectTasks := componentAttr.GetSideEffectTasks() tree.go
2070 > for idx := len(sideEffectTasks) - 1; idx >= 0; idx-- {
2071 > sideEffectTask := sideEffectTasks[idx] tree.go
2072 > if sideEffectTask.PhysicalTaskStatus == physicalTaskStatusCreated {
2073 break
2074 }
2075
2076 > node.closeTransactionGeneratePhysicalSideEffectTask( tree.go
2077 > sideEffectTask,
2078 > nodePath,
2079 > archetypeID,
2080 > )
2081 }
2082
2083 // Find the first pure task in the entire tree,
2084 // regardless if the pure task is newly added or existing.
2085 > pureTasks := componentAttr.GetPureTasks() tree.go
2086 > if len(pureTasks) == 0 {
2087 > continue tree.go
2088 }
2089
2090 > if firstPureTask == nil || tree.go
2091 > comparePureTasks(pureTasks[0], firstPureTask) < 0 {
2092 > firstPureTask = pureTasks[0]
2093 > firstPureTaskNode = node
2094 > }
2095 }
2096
2101 // task, and that component get deleted by the second task.
2102
2103 > return n.closeTransactionGeneratePhysicalPureTask( tree.go
2104 > firstPureTask,
2105 > firstPureTaskNode,
2106 > archetypeID,
2107 > )
2108 }
2109
2110 func (n *Node) deserializeComponentTask(
2111 componentTask *persistencespb.ChasmComponentAttributes_Task,
2112 > ) (any, error) { tree.go
2113 > registableTask, ok := n.registry.TaskByID(componentTask.TypeId)
2114 > if !ok {
2115 return nil, softassert.UnexpectedInternalErr(
2116 n.logger,
2119 }
2120
2121 > taskValue, err := n.deserializeTaskWithCache(registableTask, componentTask.Data) tree.go
2122 > if err != nil {
2123 return nil, err
2124 }
2125
2126 > return taskValue.Interface(), nil tree.go
2127 }
2128
2133 taskInvocation TaskInvocation,
2134 taskInstance any,
2135 > ) (_ bool, retErr error) { tree.go
2136 > registableTask, ok := n.registry.taskFor(taskInstance)
2137 > if !ok {
2138 return false, softassert.UnexpectedInternalErr(
2139 n.logger,
2144 // checkPaused=true: a single ancestor walk invalidates tasks for both
2145 // closed ancestors and paused components (self or non-detached ancestor).
2146 > if err := n.validateAccess(validateContext, true); err != nil { tree.go
2147 if errors.Is(err, errAccessCheckFailed) {
2148 return false, nil
2151 }
2152
2153 > defer log.CapturePanic(n.logger, &retErr) tree.go
2154 >
2155 > return registableTask.validateFn(
2156 > validateContext,
2157 > n.value,
2158 > taskInvocation,
2159 > taskInstance,
2160 > n.registry,
2161 > )
2162 }
2163
2164 func (n *Node) closeTransactionCleanupInvalidTasks(
2165 validateContext Context,
2166 > ) (bool, error) { tree.go
2167 > // Validate existing tasks and remove invalid ones.
2168 > var validationErr error
2169 > cleanedUp := false
2170 > deleteFunc := func(existingTask *persistencespb.ChasmComponentAttributes_Task) bool {
2171 > existingTaskInstance, err := n.deserializeComponentTask(existingTask) tree.go
2172 > if err != nil {
2173 validationErr = err
2174 return false
2175 }
2176
2177 > valid, err := n.validateTask( tree.go
2178 > validateContext,
2179 > TaskInvocation{
2180 > TaskAttributes: TaskAttributes{
2181 > ScheduledTime: existingTask.ScheduledTime.AsTime(),
2182 > Destination: existingTask.Destination,
2183 > },
2184 > },
2185 > existingTaskInstance,
2186 > )
2187 > if err != nil {
2188 validationErr = err
2189 return false
2190 }
2191 > if !valid { tree.go
2192 > cleanedUp = true tree.go
2193 > delete(n.taskValueCache, existingTask.Data)
2194 > }
2195 > return !valid tree.go
2196 }
2197
2198 > componentAttr := n.serializedNode.Metadata.GetComponentAttributes() tree.go
2199 > componentAttr.SideEffectTasks = slices.DeleteFunc(componentAttr.SideEffectTasks, deleteFunc)
2200 > if validationErr != nil {
2201 return false, validationErr
2202 }
2203 > componentAttr.PureTasks = slices.DeleteFunc(componentAttr.PureTasks, deleteFunc) tree.go
2204 > if validationErr != nil {
2205 return false, validationErr
2206 }
2207 > return cleanedUp, nil tree.go
2208 }
2209
2214 rt *RegistrableTask,
2215 taskList *[]*persistencespb.ChasmComponentAttributes_Task,
2216 > ) (skip bool) { tree.go
2217 > if rt.singletonMode == 0 {
2218 > return false tree.go
2219 > }
2220
2221 idx := slices.IndexFunc(*taskList, func(t *persistencespb.ChasmComponentAttributes_Task) bool {
2242 validateContext Context,
2243 taskOffset *int64,
2244 > ) error { tree.go
2245 > newTasks, ok := n.newTasks[n.value]
2246 > if !ok {
2247 > return nil tree.go
2248 > }
2249
2250 > componentAttr := n.serializedNode.Metadata.GetComponentAttributes() tree.go
2251 > sortPureTasks := false
2252 >
2253 > for _, newTask := range newTasks {
2254 > if !newTask.attributes.IsValid() {
2255 return softassert.UnexpectedInternalErr(
2256 n.logger,
2259 }
2260
2261 > valid, err := n.validateTask( tree.go
2262 > validateContext,
2263 > TaskInvocation{TaskAttributes: newTask.attributes},
2264 > newTask.task,
2265 > )
2266 > if err != nil {
2267 return err
2268 }
2269 > if !valid { tree.go
2270 > continue tree.go
2271 }
2272
2273 > registrableTask, ok := n.registry.taskFor(newTask.task) tree.go
2274 > if !ok {
2275 return softassert.UnexpectedInternalErr(
2276 n.logger,
2279 }
2280
2281 > taskBlob, err := n.serializeTaskWithCache(registrableTask, reflect.ValueOf(newTask.task)) tree.go
2282 > if err != nil {
2283 return err
2284 }
2285
2286 > componentTask := &persistencespb.ChasmComponentAttributes_Task{ tree.go
2287 > TypeId: registrableTask.taskTypeID,
2288 > Destination: newTask.attributes.Destination,
2289 > ScheduledTime: timestamppb.New(newTask.attributes.ScheduledTime),
2290 > Data: taskBlob,
2291 > VersionedTransition: nextVersionedTransition,
2292 > VersionedTransitionOffset: *taskOffset,
2293 > PhysicalTaskStatus: physicalTaskStatusNone,
2294 > }
2295 >
2296 > if registrableTask.isPureTask {
2297 > if skip := n.applySingletonMode(registrableTask, &componentAttr.PureTasks); skip { tree.go
2298 continue
2299 }
2300 > componentAttr.PureTasks = append(componentAttr.PureTasks, componentTask) tree.go
2301 > sortPureTasks = true
2302 > } else { tree.go
2303 > if skip := n.applySingletonMode(registrableTask, &componentAttr.SideEffectTasks); skip {
2304 continue
2305 }
2306 > componentAttr.SideEffectTasks = append(componentAttr.SideEffectTasks, componentTask) tree.go
2307 }
2308
2309 > *taskOffset++ tree.go
2310 }
2311
2312 > if sortPureTasks { tree.go
2313 > // pure tasks are sorted by scheduled time. tree.go
2314 > slices.SortFunc(componentAttr.PureTasks, comparePureTasks)
2315 > }
2316
2317 > return nil tree.go
2318 }
2319
2322 nodePath []string,
2323 archetypeID ArchetypeID,
2324 > ) { tree.go
2325 > n.backend.AddTasks(&tasks.ChasmTask{
2326 > WorkflowKey: n.backend.GetWorkflowKey(),
2327 > VisibilityTimestamp: sideEffectTask.ScheduledTime.AsTime(),
2328 > Destination: sideEffectTask.Destination,
2329 > Category: taskCategory(sideEffectTask),
2330 > Info: &persistencespb.ChasmTaskInfo{
2331 > ComponentInitialVersionedTransition: n.serializedNode.Metadata.InitialVersionedTransition,
2332 > ComponentLastUpdateVersionedTransition: n.serializedNode.Metadata.LastUpdateVersionedTransition,
2333 > Path: nodePath,
2334 > TypeId: sideEffectTask.TypeId,
2335 > Data: sideEffectTask.Data,
2336 > ArchetypeId: archetypeID,
2337 > TaskVersionedTransition: sideEffectTask.VersionedTransition,
2338 > TaskVersionedTransitionOffset: sideEffectTask.VersionedTransitionOffset,
2339 > },
2340 > })
2341 > sideEffectTask.PhysicalTaskStatus = physicalTaskStatusCreated
2342 > }
2343
2344 func (n *Node) closeTransactionGeneratePhysicalPureTask(
2346 firstTaskNode *Node,
2347 archetypeID ArchetypeID,
2348 > ) error { tree.go
2349 > if firstPureTask == nil {
2350 n.backend.DeleteCHASMPureTasks(tasks.MaximumKey.FireTime)
2351 return nil
2352 }
2353
2354 > firstPureTaskScheduledTime := firstPureTask.ScheduledTime.AsTime() tree.go
2355 > n.backend.DeleteCHASMPureTasks(firstPureTaskScheduledTime)
2356 >
2357 > if firstPureTask.PhysicalTaskStatus == physicalTaskStatusCreated {
2358 > return nil tree.go
2359 > }
2360
2361 > n.backend.AddTasks(&tasks.ChasmTaskPure{ tree.go
2362 > WorkflowKey: n.backend.GetWorkflowKey(),
2363 > VisibilityTimestamp: firstPureTaskScheduledTime,
2364 > ArchetypeID: archetypeID,
2365 > })
2366 >
2367 > // We need to persist the task status change as well, so add the node
2368 > // to the list of updated nodes.
2369 > // However, since task status is a cluster local field, we don't really
2370 > // update LastUpdateVersionedTransition for this node, and the change won't be replicated.
2371 > firstPureTask.PhysicalTaskStatus = physicalTaskStatusCreated
2372 > encodedPath, err := firstTaskNode.getEncodedPath()
2373 > if err != nil {
2374 return err
2375 }
2376 > n.systemMutation.UpdatedNodes[encodedPath] = firstTaskNode.serializedNode tree.go
2377 > return nil
2378 }
2379
2445 // andAllChildren returns a sequence of all nodes in the tree starting from n, including n itself.
2446 // The sequence is depth-first, pre-order traversal.
2447 > func (n *Node) andAllChildren() iter.Seq2[[]string, *Node] { tree.go
2448 > return func(yield func([]string, *Node) bool) {
2449 > var walk func([]string, *Node) bool
2450 > walk = func(path []string, node *Node) bool {
2451 > if node == nil {
2452 return true
2453 }
2454 > if !yield(path, node) { tree.go
2455 return false
2456 }
2457 > for _, child := range node.children { tree.go
2458 > childPath := make([]string, len(path)+1) tree.go
2459 > copy(childPath, path)
2460 > childPath[len(path)] = child.nodeName
2461 > if !walk(childPath, child) {
2462 return false
2463 }
2464 }
2465 > return true tree.go
2466 }
2467 > walk(nil, n) tree.go
2468 }
2469 }
2470
2471 > func (n *Node) cleanupTransaction() { tree.go
2472 > n.mutation = NodesMutation{
2473 > UpdatedNodes: make(map[string]*persistencespb.ChasmNode),
2474 > DeletedNodes: make(map[string]struct{}),
2475 > }
2476 >
2477 > // System mutation are most likely to be empty, so we reuse existing ones if possible.
2478 > if len(n.systemMutation.UpdatedNodes) != 0 {
2479 > n.systemMutation.UpdatedNodes = make(map[string]*persistencespb.ChasmNode) tree.go
2480 > }
2481 > if len(n.systemMutation.DeletedNodes) != 0 { tree.go
2482 n.systemMutation.DeletedNodes = make(map[string]struct{})
2483 }
2484
2485 > n.newTasks = make(map[any][]taskWithAttributes) tree.go
2486 > if len(n.immediatePureTasks) != 0 {
2487 // n.immediatePureTasks should already be empty after executeImmediatePureTasks()
2488 // unless there's an error.
2490 }
2491
2492 > if len(n.pendingRequestLinks) != 0 { tree.go
2493 n.pendingRequestLinks = make(map[any]map[string][]*commonpb.Link)
2494 }
2495 > if len(n.pendingUserMetadata) != 0 { tree.go
2496 n.pendingUserMetadata = make(map[any]*sdkpb.UserMetadata)
2497 }
2498
2499 > n.needsPointerResolution = false tree.go
2500 >
2501 > // Reset per-node subtreeIsDirty on all nodes in the tree.
2502 > for _, node := range n.andAllChildren() {
2503 > node.subtreeIsDirty = false
2504 > }
2505 }
2506
2931 }
2932
2933 > func (n *Node) getEncodedPath() (string, error) { tree.go
2934 > if n.encodedPath != nil {
2935 > return *n.encodedPath, nil tree.go
2936 > }
2937 > encodePath, err := n.pathEncoder.Encode(n, n.path()) tree.go
2938 > if err == nil {
2939 > n.encodedPath = &encodePath
2940 > }
2941 > return encodePath, err
2942 }
2943
2944 > func (n *Node) path() []string { tree.go
2945 > if n.parent == nil {
2946 > return []string{}
2947 > }
2948
2949 > return append(n.parent.path(), n.nodeName) tree.go
2950 }
2951
2952 func (n *Node) findNode(
2953 path []string,
2954 > ) (*Node, bool) { tree.go
2955 > if len(path) == 0 {
2956 > return n, true
2957 > }
2958
2959 childName := path[0]
3115
3116 // ArchetypeID returns the framework's internal ID for the root component's fully qualified name.
3117 > func (n *Node) ArchetypeID() ArchetypeID { tree.go
3118 > // Root must be a component.
3119 > return n.root().serializedNode.Metadata.GetComponentAttributes().GetTypeId()
3120 > }
3121
3122 // Archetype returns the root component's fully qualified name.
3136 }
3137
3138 > func (n *Node) root() *Node { tree.go
3139 > if n.parent == nil {
3140 > return n
3141 > }
3142 > return n.parent.root() tree.go
3143 }
3144
3261 parent *Node,
3262 nodeName string,
3263 > ) *Node { tree.go
3264 > return &Node{
3265 > nodeBase: base,
3266 > parent: parent,
3267 > children: make(map[string]*Node),
3268 > nodeName: nodeName,
3269 > }
3270 > }
3271
3272 func compareSideEffectTasks(a, b *persistencespb.ChasmComponentAttributes_Task) int {
3329 func taskCategory(
3330 task *persistencespb.ChasmComponentAttributes_Task,
3331 > ) tasks.Category { tree.go
3332 > if task.TypeId == visibilityTaskTypeID {
3333 > return tasks.CategoryVisibility tree.go
3334 > }
3335
3336 if task.Destination != "" {
3348 registrableTask *RegistrableTask,
3349 taskBlob *commonpb.DataBlob,
3350 > ) (taskValue reflect.Value, retErr error) { tree.go
3351 > if cachedValue, ok := n.taskValueCache[taskBlob]; ok {
3352 > return cachedValue, nil tree.go
3353 > }
3354
3355 taskValue, err := deserializeTask(registrableTask, taskBlob)
3365 registrableTask *RegistrableTask,
3366 taskValue reflect.Value,
3367 > ) (*commonpb.DataBlob, error) { tree.go
3368 > taskBlob, err := serializeTask(registrableTask, taskValue)
3369 > if err != nil {
3370 return nil, err
3371 }
3372
3373 > n.taskValueCache[taskBlob] = taskValue tree.go
3374 > return taskBlob, nil
3375 }
3376
3435 registrableTask *RegistrableTask,
3436 taskValue reflect.Value,
3437 > ) (*commonpb.DataBlob, error) { tree.go
3438 > protoValue, ok := taskValue.Interface().(proto.Message)
3439 > if ok {
3440 > return encodeChasmBlob(protoValue) tree.go
3441 > }
3442
3443 taskGoType := registrableTask.goType
3489 taskAttributes TaskAttributes,
3490 taskInstance any,
3491 > ) (_ bool, retErr error) { tree.go
3492 > defer func() {
3493 > if retErr == nil {
3494 > // Mark this node dirty so CloseTransaction cleans up invalid tasks,
3495 > // including the current one, even if the handler made no state mutations.
3496 > n.markSubtreeDirty()
3497 > }
3498 }()
3499
3500 > registrableTask, ok := n.registry.taskFor(taskInstance) tree.go
3501 > if !ok {
3502 return false, fmt.Errorf("unknown task type for task instance goType '%s'", reflect.TypeOf(taskInstance).Name())
3503 }
3504
3505 > if !registrableTask.isPureTask { tree.go
3506 return false, fmt.Errorf("ExecutePureTask called on a SideEffect task '%s'", registrableTask.fqType())
3507 }
3508
3509 > progressIntentCtx := newContextWithOperationIntent(baseCtx, OperationIntentProgress) tree.go
3510 > validationContext := NewContext(progressIntentCtx, n)
3511 >
3512 > // Ensure this node's component value is hydrated before execution.
3513 > if err := n.prepareComponentValue(validationContext); err != nil {
3514 return false, err
3515 }
3516
3517 // Run the task's registered value before execution.
3518 > valid, err := n.validateTask(validationContext, TaskInvocation{TaskAttributes: taskAttributes}, taskInstance) tree.go
3519 > if err != nil {
3520 return false, err
3521 }
3522 > if !valid { tree.go
3523 return false, nil
3524 }
3525
3526 > executionContext := NewMutableContext(progressIntentCtx, n) tree.go
3527 > component, err := n.Component(executionContext, ComponentRef{})
3528 > if err != nil {
3529 return false, err
3530 }
3531
3532 > defer log.CapturePanic(n.logger, &retErr) tree.go
3533 >
3534 > archetypeTag := metrics.ArchetypeTag("")
3535 > if name, ok := n.registry.ArchetypeDisplayName(n.ArchetypeID()); ok {
3536 > archetypeTag = metrics.ArchetypeTag(name)
3537 > }
3538 > chasmTaskTypeTag := metrics.ChasmTaskTypeTag(registrableTask.fqType())
3539 > metricsHandler := n.metricsHandler.WithTags(archetypeTag)
3540 >
3541 > execErr := registrableTask.pureTaskExecuteFn(
3542 > executionContext,
3543 > component,
3544 > taskAttributes,
3545 > taskInstance,
3546 > n.registry,
3547 > )
3548 >
3549 > metrics.ChasmPureTaskRequests.With(metricsHandler).Record(1, chasmTaskTypeTag)
3550 >
3551 > if execErr != nil {
3552 metrics.ChasmPureTaskErrors.With(metricsHandler).Record(1, chasmTaskTypeTag)
3553 return true, execErr
3561 // See: https://github.com/temporalio/temporal/pull/7701#discussion_r2072026993
3562
3563 > return true, nil tree.go
3564 }
3565
3868 // encodeChasmBlob encodes CHASM data and task payloads through the env-aware
3869 // serializer while preserving deterministic proto3 bytes for byte comparisons.
3870 > func encodeChasmBlob(m proto.Message) (*commonpb.DataBlob, error) { tree.go
3871 > return serialization.Encode(m, serialization.WithDeterministicProto3)
3872 > }
go.temporal.io/server/common/dynamicconfig/setting_gen.go 245 covered LOC · 51 ranges

Open complete file

26 type GlobalBoolConstrainedDefaultSetting = GlobalTypedConstrainedDefaultSetting[bool]
27
28 > func NewGlobalBoolSetting(key string, def bool, description string) GlobalBoolSetting { setting_gen.go
29 > return NewGlobalTypedSettingWithConverter[bool](key, convertBool, def, description)
30 > }
31
32 func NewGlobalBoolSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[bool], description string) GlobalBoolConstrainedDefaultSetting {
43 type NamespaceBoolConstrainedDefaultSetting = NamespaceTypedConstrainedDefaultSetting[bool]
44
45 > func NewNamespaceBoolSetting(key string, def bool, description string) NamespaceBoolSetting { setting_gen.go
46 > return NewNamespaceTypedSettingWithConverter[bool](key, convertBool, def, description)
47 > }
48
49 func NewNamespaceBoolSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[bool], description string) NamespaceBoolConstrainedDefaultSetting {
60 type NamespaceIDBoolConstrainedDefaultSetting = NamespaceIDTypedConstrainedDefaultSetting[bool]
61
62 > func NewNamespaceIDBoolSetting(key string, def bool, description string) NamespaceIDBoolSetting { setting_gen.go
63 > return NewNamespaceIDTypedSettingWithConverter[bool](key, convertBool, def, description)
64 > }
65
66 func NewNamespaceIDBoolSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[bool], description string) NamespaceIDBoolConstrainedDefaultSetting {
77 type TaskQueueBoolConstrainedDefaultSetting = TaskQueueTypedConstrainedDefaultSetting[bool]
78
79 > func NewTaskQueueBoolSetting(key string, def bool, description string) TaskQueueBoolSetting { setting_gen.go
80 > return NewTaskQueueTypedSettingWithConverter[bool](key, convertBool, def, description)
81 > }
82
83 func NewTaskQueueBoolSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[bool], description string) TaskQueueBoolConstrainedDefaultSetting {
128 type DestinationBoolConstrainedDefaultSetting = DestinationTypedConstrainedDefaultSetting[bool]
129
130 > func NewDestinationBoolSetting(key string, def bool, description string) DestinationBoolSetting { setting_gen.go
131 > return NewDestinationTypedSettingWithConverter[bool](key, convertBool, def, description)
132 > }
133
134 func NewDestinationBoolSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[bool], description string) DestinationBoolConstrainedDefaultSetting {
162 type GlobalIntConstrainedDefaultSetting = GlobalTypedConstrainedDefaultSetting[int]
163
164 > func NewGlobalIntSetting(key string, def int, description string) GlobalIntSetting { setting_gen.go
165 > return NewGlobalTypedSettingWithConverter[int](key, convertInt, def, description)
166 > }
167
168 func NewGlobalIntSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[int], description string) GlobalIntConstrainedDefaultSetting {
179 type NamespaceIntConstrainedDefaultSetting = NamespaceTypedConstrainedDefaultSetting[int]
180
181 > func NewNamespaceIntSetting(key string, def int, description string) NamespaceIntSetting { setting_gen.go
182 > return NewNamespaceTypedSettingWithConverter[int](key, convertInt, def, description)
183 > }
184
185 func NewNamespaceIntSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[int], description string) NamespaceIntConstrainedDefaultSetting {
189 type IntPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[int]
190
191 > func GetIntPropertyFnFilteredByNamespace(value int) IntPropertyFnWithNamespaceFilter { setting_gen.go
192 > return GetTypedPropertyFnFilteredByNamespace(value)
193 > }
194
195 type NamespaceIDIntSetting = NamespaceIDTypedSetting[int]
213 type TaskQueueIntConstrainedDefaultSetting = TaskQueueTypedConstrainedDefaultSetting[int]
214
215 > func NewTaskQueueIntSetting(key string, def int, description string) TaskQueueIntSetting { setting_gen.go
216 > return NewTaskQueueTypedSettingWithConverter[int](key, convertInt, def, description)
217 > }
218
219 > func NewTaskQueueIntSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[int], description string) TaskQueueIntConstrainedDefaultSetting { setting_gen.go
220 > return NewTaskQueueTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
221 > }
222
223 type IntPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[int]
230 type ShardIDIntConstrainedDefaultSetting = ShardIDTypedConstrainedDefaultSetting[int]
231
232 > func NewShardIDIntSetting(key string, def int, description string) ShardIDIntSetting { setting_gen.go
233 > return NewShardIDTypedSettingWithConverter[int](key, convertInt, def, description)
234 > }
235
236 func NewShardIDIntSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[int], description string) ShardIDIntConstrainedDefaultSetting {
264 type DestinationIntConstrainedDefaultSetting = DestinationTypedConstrainedDefaultSetting[int]
265
266 > func NewDestinationIntSetting(key string, def int, description string) DestinationIntSetting { setting_gen.go
267 > return NewDestinationTypedSettingWithConverter[int](key, convertInt, def, description)
268 > }
269
270 func NewDestinationIntSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[int], description string) DestinationIntConstrainedDefaultSetting {
298 type GlobalFloatConstrainedDefaultSetting = GlobalTypedConstrainedDefaultSetting[float64]
299
300 > func NewGlobalFloatSetting(key string, def float64, description string) GlobalFloatSetting { setting_gen.go
301 > return NewGlobalTypedSettingWithConverter[float64](key, convertFloat, def, description)
302 > }
303
304 func NewGlobalFloatSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[float64], description string) GlobalFloatConstrainedDefaultSetting {
315 type NamespaceFloatConstrainedDefaultSetting = NamespaceTypedConstrainedDefaultSetting[float64]
316
317 > func NewNamespaceFloatSetting(key string, def float64, description string) NamespaceFloatSetting { setting_gen.go
318 > return NewNamespaceTypedSettingWithConverter[float64](key, convertFloat, def, description)
319 > }
320
321 func NewNamespaceFloatSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[float64], description string) NamespaceFloatConstrainedDefaultSetting {
349 type TaskQueueFloatConstrainedDefaultSetting = TaskQueueTypedConstrainedDefaultSetting[float64]
350
351 > func NewTaskQueueFloatSetting(key string, def float64, description string) TaskQueueFloatSetting { setting_gen.go
352 > return NewTaskQueueTypedSettingWithConverter[float64](key, convertFloat, def, description)
353 > }
354
355 func NewTaskQueueFloatSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[float64], description string) TaskQueueFloatConstrainedDefaultSetting {
366 type ShardIDFloatConstrainedDefaultSetting = ShardIDTypedConstrainedDefaultSetting[float64]
367
368 > func NewShardIDFloatSetting(key string, def float64, description string) ShardIDFloatSetting { setting_gen.go
369 > return NewShardIDTypedSettingWithConverter[float64](key, convertFloat, def, description)
370 > }
371
372 func NewShardIDFloatSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[float64], description string) ShardIDFloatConstrainedDefaultSetting {
400 type DestinationFloatConstrainedDefaultSetting = DestinationTypedConstrainedDefaultSetting[float64]
401
402 > func NewDestinationFloatSetting(key string, def float64, description string) DestinationFloatSetting { setting_gen.go
403 > return NewDestinationTypedSettingWithConverter[float64](key, convertFloat, def, description)
404 > }
405
406 func NewDestinationFloatSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[float64], description string) DestinationFloatConstrainedDefaultSetting {
434 type GlobalStringConstrainedDefaultSetting = GlobalTypedConstrainedDefaultSetting[string]
435
436 > func NewGlobalStringSetting(key string, def string, description string) GlobalStringSetting { setting_gen.go
437 > return NewGlobalTypedSettingWithConverter[string](key, convertString, def, description)
438 > }
439
440 func NewGlobalStringSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[string], description string) GlobalStringConstrainedDefaultSetting {
570 type GlobalDurationConstrainedDefaultSetting = GlobalTypedConstrainedDefaultSetting[time.Duration]
571
572 > func NewGlobalDurationSetting(key string, def time.Duration, description string) GlobalDurationSetting { setting_gen.go
573 > return NewGlobalTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
574 > }
575
576 func NewGlobalDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) GlobalDurationConstrainedDefaultSetting {
587 type NamespaceDurationConstrainedDefaultSetting = NamespaceTypedConstrainedDefaultSetting[time.Duration]
588
589 > func NewNamespaceDurationSetting(key string, def time.Duration, description string) NamespaceDurationSetting { setting_gen.go
590 > return NewNamespaceTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
591 > }
592
593 func NewNamespaceDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) NamespaceDurationConstrainedDefaultSetting {
604 type NamespaceIDDurationConstrainedDefaultSetting = NamespaceIDTypedConstrainedDefaultSetting[time.Duration]
605
606 > func NewNamespaceIDDurationSetting(key string, def time.Duration, description string) NamespaceIDDurationSetting { setting_gen.go
607 > return NewNamespaceIDTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
608 > }
609
610 func NewNamespaceIDDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) NamespaceIDDurationConstrainedDefaultSetting {
621 type TaskQueueDurationConstrainedDefaultSetting = TaskQueueTypedConstrainedDefaultSetting[time.Duration]
622
623 > func NewTaskQueueDurationSetting(key string, def time.Duration, description string) TaskQueueDurationSetting { setting_gen.go
624 > return NewTaskQueueTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
625 > }
626
627 > func NewTaskQueueDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) TaskQueueDurationConstrainedDefaultSetting { setting_gen.go
628 > return NewTaskQueueTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
629 > }
630
631 type DurationPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[time.Duration]
638 type ShardIDDurationConstrainedDefaultSetting = ShardIDTypedConstrainedDefaultSetting[time.Duration]
639
640 > func NewShardIDDurationSetting(key string, def time.Duration, description string) ShardIDDurationSetting { setting_gen.go
641 > return NewShardIDTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
642 > }
643
644 func NewShardIDDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) ShardIDDurationConstrainedDefaultSetting {
655 type TaskTypeDurationConstrainedDefaultSetting = TaskTypeTypedConstrainedDefaultSetting[time.Duration]
656
657 > func NewTaskTypeDurationSetting(key string, def time.Duration, description string) TaskTypeDurationSetting { setting_gen.go
658 > return NewTaskTypeTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
659 > }
660
661 func NewTaskTypeDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) TaskTypeDurationConstrainedDefaultSetting {
672 type DestinationDurationConstrainedDefaultSetting = DestinationTypedConstrainedDefaultSetting[time.Duration]
673
674 > func NewDestinationDurationSetting(key string, def time.Duration, description string) DestinationDurationSetting { setting_gen.go
675 > return NewDestinationTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
676 > }
677
678 func NewDestinationDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) DestinationDurationConstrainedDefaultSetting {
689 type ChasmTaskTypeDurationConstrainedDefaultSetting = ChasmTaskTypeTypedConstrainedDefaultSetting[time.Duration]
690
691 > func NewChasmTaskTypeDurationSetting(key string, def time.Duration, description string) ChasmTaskTypeDurationSetting { setting_gen.go
692 > return NewChasmTaskTypeTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
693 > }
694
695 func NewChasmTaskTypeDurationSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[time.Duration], description string) ChasmTaskTypeDurationConstrainedDefaultSetting {
723 type NamespaceMapConstrainedDefaultSetting = NamespaceTypedConstrainedDefaultSetting[map[string]any]
724
725 > func NewNamespaceMapSetting(key string, def map[string]any, description string) NamespaceMapSetting { setting_gen.go
726 > return NewNamespaceTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
727 > }
728
729 func NewNamespaceMapSettingWithConstrainedDefault(key string, cdef []TypedConstrainedValue[map[string]any], description string) NamespaceMapConstrainedDefaultSetting {
845 // values. The value from dynamic config will be _merged_ over a deep copy of 'def'. Be very careful
846 // when using non-empty maps or slices as defaults, the result may not be what you want.
847 > func NewGlobalTypedSetting[T any](key string, def T, description string) GlobalTypedSetting[T] { setting_gen.go
848 > // Warn on any shared structure used with ConvertStructure, even though we handle it by deep copying.
849 > warnDefaultSharedStructure(key, def)
850 > // If even deep copy won't even work, we should panic early. Do that by calling deep copy once here.
851 > _ = deepCopyForMapstructure(def)
852 >
853 > s := GlobalTypedSetting[T]{
854 > key: MakeKey(key),
855 > def: def,
856 > convert: ConvertStructure[T](def),
857 > description: description,
858 > }
859 > register(s)
860 > return s
861 > }
862
863 // NewGlobalTypedSettingWithConverter creates a setting with a custom converter function.
864 > func NewGlobalTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) GlobalTypedSetting[T] { setting_gen.go
865 > s := GlobalTypedSetting[T]{
866 > key: MakeKey(key),
867 > def: def,
868 > convert: convert,
869 > description: description,
870 > }
871 > register(s)
872 > return s
873 > }
874
875 // NewGlobalTypedSettingWithConstrainedDefault creates a setting with a compound default value.
885 }
886
887 > func (s GlobalTypedSetting[T]) Key() Key { return s.key } setting_gen.go
888 func (s GlobalTypedSetting[T]) Precedence() Precedence { return PrecedenceGlobal }
889 func (s GlobalTypedSetting[T]) Validate(v any) error {
981 // values. The value from dynamic config will be _merged_ over a deep copy of 'def'. Be very careful
982 // when using non-empty maps or slices as defaults, the result may not be what you want.
983 > func NewNamespaceTypedSetting[T any](key string, def T, description string) NamespaceTypedSetting[T] { setting_gen.go
984 > // Warn on any shared structure used with ConvertStructure, even though we handle it by deep copying.
985 > warnDefaultSharedStructure(key, def)
986 > // If even deep copy won't even work, we should panic early. Do that by calling deep copy once here.
987 > _ = deepCopyForMapstructure(def)
988 >
989 > s := NamespaceTypedSetting[T]{
990 > key: MakeKey(key),
991 > def: def,
992 > convert: ConvertStructure[T](def),
993 > description: description,
994 > }
995 > register(s)
996 > return s
997 > }
998
999 // NewNamespaceTypedSettingWithConverter creates a setting with a custom converter function.
1000 > func NewNamespaceTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) NamespaceTypedSetting[T] { setting_gen.go
1001 > s := NamespaceTypedSetting[T]{
1002 > key: MakeKey(key),
1003 > def: def,
1004 > convert: convert,
1005 > description: description,
1006 > }
1007 > register(s)
1008 > return s
1009 > }
1010
1011 // NewNamespaceTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1021 }
1022
1023 > func (s NamespaceTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1024 func (s NamespaceTypedSetting[T]) Precedence() Precedence { return PrecedenceNamespace }
1025 func (s NamespaceTypedSetting[T]) Validate(v any) error {
1105 }
1106
1107 > func GetTypedPropertyFnFilteredByNamespace[T any](value T) TypedPropertyFnWithNamespaceFilter[T] { setting_gen.go
1108 > return func(namespace string) T {
1109 return value
1110 }
1134
1135 // NewNamespaceIDTypedSettingWithConverter creates a setting with a custom converter function.
1136 > func NewNamespaceIDTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) NamespaceIDTypedSetting[T] { setting_gen.go
1137 > s := NamespaceIDTypedSetting[T]{
1138 > key: MakeKey(key),
1139 > def: def,
1140 > convert: convert,
1141 > description: description,
1142 > }
1143 > register(s)
1144 > return s
1145 > }
1146
1147 // NewNamespaceIDTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1157 }
1158
1159 > func (s NamespaceIDTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1160 func (s NamespaceIDTypedSetting[T]) Precedence() Precedence { return PrecedenceNamespaceID }
1161 func (s NamespaceIDTypedSetting[T]) Validate(v any) error {
1253 // values. The value from dynamic config will be _merged_ over a deep copy of 'def'. Be very careful
1254 // when using non-empty maps or slices as defaults, the result may not be what you want.
1255 > func NewTaskQueueTypedSetting[T any](key string, def T, description string) TaskQueueTypedSetting[T] { setting_gen.go
1256 > // Warn on any shared structure used with ConvertStructure, even though we handle it by deep copying.
1257 > warnDefaultSharedStructure(key, def)
1258 > // If even deep copy won't even work, we should panic early. Do that by calling deep copy once here.
1259 > _ = deepCopyForMapstructure(def)
1260 >
1261 > s := TaskQueueTypedSetting[T]{
1262 > key: MakeKey(key),
1263 > def: def,
1264 > convert: ConvertStructure[T](def),
1265 > description: description,
1266 > }
1267 > register(s)
1268 > return s
1269 > }
1270
1271 // NewTaskQueueTypedSettingWithConverter creates a setting with a custom converter function.
1272 > func NewTaskQueueTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) TaskQueueTypedSetting[T] { setting_gen.go
1273 > s := TaskQueueTypedSetting[T]{
1274 > key: MakeKey(key),
1275 > def: def,
1276 > convert: convert,
1277 > description: description,
1278 > }
1279 > register(s)
1280 > return s
1281 > }
1282
1283 // NewTaskQueueTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1284 > func NewTaskQueueTypedSettingWithConstrainedDefault[T any](key string, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) TaskQueueTypedConstrainedDefaultSetting[T] { setting_gen.go
1285 > s := TaskQueueTypedConstrainedDefaultSetting[T]{
1286 > key: MakeKey(key),
1287 > cdef: cdef,
1288 > convert: convert,
1289 > description: description,
1290 > }
1291 > register(s)
1292 > return s
1293 > }
1294
1295 > func (s TaskQueueTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1296 func (s TaskQueueTypedSetting[T]) Precedence() Precedence { return PrecedenceTaskQueue }
1297 func (s TaskQueueTypedSetting[T]) Validate(v any) error {
1300 }
1301
1302 > func (s TaskQueueTypedConstrainedDefaultSetting[T]) Key() Key { return s.key } setting_gen.go
1303 func (s TaskQueueTypedConstrainedDefaultSetting[T]) Precedence() Precedence { return PrecedenceTaskQueue }
1304 func (s TaskQueueTypedConstrainedDefaultSetting[T]) Validate(v any) error {
1430
1431 // NewShardIDTypedSettingWithConverter creates a setting with a custom converter function.
1432 > func NewShardIDTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) ShardIDTypedSetting[T] { setting_gen.go
1433 > s := ShardIDTypedSetting[T]{
1434 > key: MakeKey(key),
1435 > def: def,
1436 > convert: convert,
1437 > description: description,
1438 > }
1439 > register(s)
1440 > return s
1441 > }
1442
1443 // NewShardIDTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1453 }
1454
1455 > func (s ShardIDTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1456 func (s ShardIDTypedSetting[T]) Precedence() Precedence { return PrecedenceShardID }
1457 func (s ShardIDTypedSetting[T]) Validate(v any) error {
1566
1567 // NewTaskTypeTypedSettingWithConverter creates a setting with a custom converter function.
1568 > func NewTaskTypeTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) TaskTypeTypedSetting[T] { setting_gen.go
1569 > s := TaskTypeTypedSetting[T]{
1570 > key: MakeKey(key),
1571 > def: def,
1572 > convert: convert,
1573 > description: description,
1574 > }
1575 > register(s)
1576 > return s
1577 > }
1578
1579 // NewTaskTypeTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1589 }
1590
1591 > func (s TaskTypeTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1592 func (s TaskTypeTypedSetting[T]) Precedence() Precedence { return PrecedenceTaskType }
1593 func (s TaskTypeTypedSetting[T]) Validate(v any) error {
1685 // values. The value from dynamic config will be _merged_ over a deep copy of 'def'. Be very careful
1686 // when using non-empty maps or slices as defaults, the result may not be what you want.
1687 > func NewDestinationTypedSetting[T any](key string, def T, description string) DestinationTypedSetting[T] { setting_gen.go
1688 > // Warn on any shared structure used with ConvertStructure, even though we handle it by deep copying.
1689 > warnDefaultSharedStructure(key, def)
1690 > // If even deep copy won't even work, we should panic early. Do that by calling deep copy once here.
1691 > _ = deepCopyForMapstructure(def)
1692 >
1693 > s := DestinationTypedSetting[T]{
1694 > key: MakeKey(key),
1695 > def: def,
1696 > convert: ConvertStructure[T](def),
1697 > description: description,
1698 > }
1699 > register(s)
1700 > return s
1701 > }
1702
1703 // NewDestinationTypedSettingWithConverter creates a setting with a custom converter function.
1704 > func NewDestinationTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) DestinationTypedSetting[T] { setting_gen.go
1705 > s := DestinationTypedSetting[T]{
1706 > key: MakeKey(key),
1707 > def: def,
1708 > convert: convert,
1709 > description: description,
1710 > }
1711 > register(s)
1712 > return s
1713 > }
1714
1715 // NewDestinationTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1725 }
1726
1727 > func (s DestinationTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1728 func (s DestinationTypedSetting[T]) Precedence() Precedence { return PrecedenceDestination }
1729 func (s DestinationTypedSetting[T]) Validate(v any) error {
1858
1859 // NewChasmTaskTypeTypedSettingWithConverter creates a setting with a custom converter function.
1860 > func NewChasmTaskTypeTypedSettingWithConverter[T any](key string, convert func(any) (T, error), def T, description string) ChasmTaskTypeTypedSetting[T] { setting_gen.go
1861 > s := ChasmTaskTypeTypedSetting[T]{
1862 > key: MakeKey(key),
1863 > def: def,
1864 > convert: convert,
1865 > description: description,
1866 > }
1867 > register(s)
1868 > return s
1869 > }
1870
1871 // NewChasmTaskTypeTypedSettingWithConstrainedDefault creates a setting with a compound default value.
1881 }
1882
1883 > func (s ChasmTaskTypeTypedSetting[T]) Key() Key { return s.key } setting_gen.go
1884 func (s ChasmTaskTypeTypedSetting[T]) Precedence() Precedence { return PrecedenceChasmTaskType }
1885 func (s ChasmTaskTypeTypedSetting[T]) Validate(v any) error {
go.temporal.io/server/chasm/lib/scheduler/scheduler.go 143 covered LOC · 31 ranges

Open complete file

121 input *schedulepb.Schedule,
122 patch *schedulepb.SchedulePatch,
123 > ) (*Scheduler, error) { scheduler.go
124 > var zero time.Time
125 >
126 > sched := &Scheduler{
127 > SchedulerState: &schedulerpb.SchedulerState{
128 > Schedule: input,
129 > Info: &schedulepb.ScheduleInfo{
130 > UpdateTime: timestamppb.New(zero),
131 > },
132 > Namespace: namespace,
133 > NamespaceId: namespaceID,
134 > ScheduleId: scheduleID,
135 > ConflictToken: scheduler.InitialConflictToken,
136 > },
137 > cacheConflictToken: scheduler.InitialConflictToken,
138 > Backfillers: make(chasm.Map[string, *Backfiller]),
139 > LastCompletionResult: chasm.NewDataField(ctx, &schedulerpb.LastCompletionResult{}),
140 > EventLog: chasm.NewComponentField(ctx, NewEventLog(ctx)),
141 > }
142 > sched.setNullableFields()
143 > sched.Info.CreateTime = timestamppb.New(ctx.Now(sched))
144 >
145 > invoker := NewInvoker(ctx)
146 > sched.Invoker = chasm.NewComponentField(ctx, invoker)
147 >
148 > generator := NewGenerator(ctx)
149 > sched.Generator = chasm.NewComponentField(ctx, generator)
150 >
151 > // Create backfillers to fulfill initialPatch.
152 > if err := sched.handlePatch(ctx, patch); err != nil {
153 return nil, err
154 }
155 > visibility := chasm.NewVisibility(ctx) scheduler.go
156 > sched.Visibility = chasm.NewComponentField(ctx, visibility)
157 >
158 > return sched, nil
159 }
160
201
202 // IsSentinel returns true if this is a sentinel scheduler.
203 > func (s *Scheduler) IsSentinel() bool { scheduler.go
204 > return s.Sentinel
205 > }
206
207 // setNullableFields sets fields that are nullable in API requests.
208 > func (s *Scheduler) setNullableFields() { scheduler.go
209 > if s.Schedule.Policies == nil {
210 s.Schedule.Policies = &schedulepb.SchedulePolicies{}
211 }
212 > if s.Schedule.State == nil { scheduler.go
213 s.Schedule.State = &schedulepb.ScheduleState{}
214 }
216
217 // handlePatch creates backfillers to fulfill the given patch request.
218 > func (s *Scheduler) handlePatch(ctx chasm.MutableContext, patch *schedulepb.SchedulePatch) error { scheduler.go
219 > if patch == nil {
220 > return nil
221 > }
222
223 // Each TriggerImmediately and BackfillRequest creates exactly one backfiller.
321
322 // LifecycleState implements the chasm.Component interface.
323 > func (s *Scheduler) LifecycleState(ctx chasm.Context) chasm.LifecycleState { scheduler.go
324 > if s.Closed {
325 return chasm.LifecycleStateCompleted
326 }
327
328 > return chasm.LifecycleStateRunning scheduler.go
329 }
330
390 // decremented when an action can be taken. When decrement is false, no state
391 // is mutated.
392 > func (s *Scheduler) useScheduledAction(decrement bool) bool { scheduler.go
393 > scheduleState := s.Schedule.GetState()
394 >
395 > // If paused, don't do anything.
396 > if scheduleState.Paused {
397 return false
398 }
399
400 // If unlimited actions, allow.
401 > if !scheduleState.LimitedActions { scheduler.go
402 > return true
403 > }
404
405 // Otherwise check and decrement limit.
420 }
421
422 > func (s *Scheduler) getCompiledSpec(specBuilder *scheduler.SpecBuilder) (*scheduler.CompiledSpec, error) { scheduler.go
423 > s.validateCachedState()
424 >
425 > // Cache compiled spec.
426 > if s.compiledSpec == nil {
427 > cspec, err := specBuilder.NewCompiledSpec(s.Schedule.Spec)
428 > if err != nil {
429 return nil, err
430 }
431 > s.compiledSpec = cspec scheduler.go
432 }
433
434 > return s.compiledSpec, nil scheduler.go
435 }
436
437 // WorkflowID returns the Workflow ID given as part of the request spec.
438 // During start generation, nominal time is suffixed to this ID.
439 > func (s *Scheduler) WorkflowID() string { scheduler.go
440 > return s.Schedule.GetAction().GetStartWorkflow().GetWorkflowId()
441 > }
442
443 > func (s *Scheduler) jitterSeed() string { scheduler.go
444 > return fmt.Sprintf("%s-%s", s.NamespaceId, s.ScheduleId)
445 > }
446
447 func (s *Scheduler) identity() string {
449 }
450
451 > func (s *Scheduler) overlapPolicy() enumspb.ScheduleOverlapPolicy { scheduler.go
452 > policy := s.Schedule.GetPolicies().GetOverlapPolicy()
453 > if policy == enumspb.SCHEDULE_OVERLAP_POLICY_UNSPECIFIED {
454 > policy = enumspb.SCHEDULE_OVERLAP_POLICY_SKIP
455 > }
456 > return policy
457 }
458
467 // ConflictToken doesn't match its cacheConflictToken field. Validation is only
468 // as effective as the Scheduler's backing persisted state is up-to-date.
469 > func (s *Scheduler) validateCachedState() { scheduler.go
470 > if s.cacheConflictToken != s.ConflictToken {
471 // Bust stale cached fields.
472 s.compiledSpec = nil
511 // matching V1's RetentionTime semantics, where lastEventTime is advanced by
512 // manual triggers via recentActions.
513 > func (s *Scheduler) isHeldOpen() bool { scheduler.go
514 > if s.IsSentinel() {
515 return false
516 }
517 > return s.Schedule.GetState().GetPaused() || scheduler.go
518 > s.hasMoreBackfills()
519 }
520
536 idleTime time.Duration,
537 nextWakeup time.Time,
538 > ) (time.Time, bool) { scheduler.go
539 > if idleTime == 0 ||
540 > s.isHeldOpen() ||
541 > (!nextWakeup.IsZero() && s.useScheduledAction(false)) {
542 > return time.Time{}, false
543 > }
544 return s.idleDeadline(ctx, idleTime), true
545 }
546
547 > func (s *Scheduler) hasMoreBackfills() bool { scheduler.go
548 > return len(s.Backfillers) > 0
549 > }
550
551 type schedulerActionResult struct {
974 }
975
976 > func (s *Scheduler) executionStatus() string { scheduler.go
977 > if s.Closed {
978 return executionStatusCompleted
979 }
980 > return executionStatusRunning scheduler.go
981 }
982
983 // SearchAttributes returns the Temporal-managed key values for visibility.
984 > func (s *Scheduler) SearchAttributes(ctx chasm.Context) []chasm.SearchAttributeKeyValue { scheduler.go
985 > if s.Sentinel {
986 return []chasm.SearchAttributeKeyValue{
987 executionStatusSearchAttribute.Value(s.executionStatus()),
988 }
989 }
990 > out := []chasm.SearchAttributeKeyValue{ scheduler.go
991 > executionStatusSearchAttribute.Value(s.executionStatus()),
992 > chasm.SearchAttributeTemporalSchedulePaused.Value(s.Schedule.GetState().GetPaused()),
993 > }
994 > if !s.Closed {
995 > if gen := s.Generator.Get(ctx); len(gen.FutureActionTimes) > 0 {
996 > out = append(out, scheduleNextActionTimeSearchAttribute.Value(gen.FutureActionTimes[0].AsTime()))
997 > }
998 > if s.IdleCloseTime != nil {
999 > out = append(out, scheduleIdleCloseTimeSearchAttribute.Value(s.IdleCloseTime.AsTime())) scheduler.go
1000 > }
1001
1002 > invoker := s.Invoker.Get(ctx) scheduler.go
1003 > runningWorkflowCount := int64(len(invoker.runningWorkflowExecutions()))
1004 > bufferedStartsCount := int64(len(invoker.GetBufferedStarts()) - len(invoker.recentActions()))
1005 >
1006 > // Emitted even when zero so that exact and range queries both work.
1007 > out = append(out,
1008 > scheduleRunningWorkflowCountSearchAttribute.Value(runningWorkflowCount),
1009 > scheduleBufferedStartsCountSearchAttribute.Value(bufferedStartsCount),
1010 > )
1011 }
1012 > return out scheduler.go
1013 }
1014
1016 func (s *Scheduler) Memo(
1017 ctx chasm.Context,
1018 > ) proto.Message { scheduler.go
1019 > if s.Sentinel {
1020 return nil
1021 }
1022 > return s.ListInfo(ctx) scheduler.go
1023 }
1024
1027 func (s *Scheduler) ListInfo(
1028 ctx chasm.Context,
1029 > ) *schedulepb.ScheduleListInfo { scheduler.go
1030 > spec := common.CloneProto(s.Schedule.Spec)
1031 >
1032 > // Clear fields that are too large/not useful for the list view.
1033 > spec.TimezoneData = nil
1034 >
1035 > // Limit the number of specs and exclusions stored on the memo.
1036 > spec.ExcludeStructuredCalendar = util.SliceHead(spec.ExcludeStructuredCalendar, listInfoSpecFieldLimit)
1037 > spec.Interval = util.SliceHead(spec.Interval, listInfoSpecFieldLimit)
1038 > spec.StructuredCalendar = util.SliceHead(spec.StructuredCalendar, listInfoSpecFieldLimit)
1039 >
1040 > generator := s.Generator.Get(ctx)
1041 > invoker := s.Invoker.Get(ctx)
1042 >
1043 > return &schedulepb.ScheduleListInfo{
1044 > Spec: spec,
1045 > WorkflowType: s.Schedule.Action.GetStartWorkflow().GetWorkflowType(),
1046 > Notes: s.Schedule.State.Notes,
1047 > Paused: s.Schedule.State.Paused,
1048 > RecentActions: invoker.recentActions(),
1049 > FutureActionTimes: generator.FutureActionTimes,
1050 > }
1051 > }
1052
1053 // startWorkflowSearchAttributes returns the search attributes to be applied to
go.temporal.io/server/service/worker/scheduler/spec.go 141 covered LOC · 45 ranges

Open complete file

63 // NewSpecBuilder takes the compute-limit getters directly (rather than a *dynamicconfig.Collection)
64 // so the dynamic-config plumbing stays in the wiring layer, per the common codebase pattern.
65 > func NewSpecBuilder(warnIterations, maxIterations dynamicconfig.IntPropertyFn) *SpecBuilder { spec.go
66 > return &SpecBuilder{
67 > warnIterations: warnIterations,
68 > maxIterations: maxIterations,
69 > locationCache: cache.New(1000,
70 > &cache.Options{
71 > TTL: 24 * time.Hour,
72 > },
73 > ),
74 > }
75 > }
76
77 > func (b *SpecBuilder) NewCompiledSpec(spec *schedulepb.ScheduleSpec) (*CompiledSpec, error) { spec.go
78 > spec, err := canonicalizeSpec(spec)
79 > if err != nil {
80 return nil, err
81 }
82
83 // load timezone
84 > tz, err := b.loadTimezone(spec) spec.go
85 > if err != nil {
86 return nil, err
87 }
88
89 // compile StructuredCalendarSpecs
90 > ccs := make([]*compiledCalendar, len(spec.StructuredCalendar)) spec.go
91 > for i, structured := range spec.StructuredCalendar {
92 ccs[i] = newCompiledCalendar(structured, tz)
93 }
94
95 // compile excludes
96 > excludes := make([]*compiledCalendar, len(spec.ExcludeStructuredCalendar)) spec.go
97 > for i, excal := range spec.ExcludeStructuredCalendar {
98 excludes[i] = newCompiledCalendar(excal, tz)
99 }
100
101 > cspec := &CompiledSpec{ spec.go
102 > spec: spec,
103 > tz: tz,
104 > calendar: ccs,
105 > excludes: excludes,
106 > warnIterations: b.warnIterations,
107 > maxIterations: b.maxIterations,
108 > }
109 >
110 > return cspec, nil
111 }
112
141
142 //revive:disable-next-line:cognitive-complexity
143 > func canonicalizeSpec(spec *schedulepb.ScheduleSpec) (*schedulepb.ScheduleSpec, error) { spec.go
144 > // make copy so we can change some fields
145 > spec = common.CloneProto(spec)
146 >
147 > // parse CalendarSpecs to StructuredCalendarSpecs
148 > for _, cal := range spec.Calendar {
149 structured, err := parseCalendarToStructured(cal)
150 if err != nil {
153 spec.StructuredCalendar = append(spec.StructuredCalendar, structured)
154 }
155 > spec.Calendar = nil spec.go
156 >
157 > // parse ExcludeCalendars
158 > for _, cal := range spec.ExcludeCalendar {
159 structured, err := parseCalendarToStructured(cal)
160 if err != nil {
163 spec.ExcludeStructuredCalendar = append(spec.ExcludeStructuredCalendar, structured)
164 }
165 > spec.ExcludeCalendar = nil spec.go
166 >
167 > // parse CronStrings
168 > const unset = "__unset__"
169 > cronTZ := unset
170 > for _, cs := range spec.CronString {
171 structured, interval, tz, err := parseCronString(cs)
172 if err != nil {
185 }
186 }
187 > spec.CronString = nil spec.go
188 >
189 > // if we have cron string(s), copy the timezone to spec, checking for conflict first.
190 > // if cron string timezone is empty string, don't copy, let the one in spec be used.
191 > if cronTZ != unset && cronTZ != "" {
192 if spec.TimezoneName != "" && spec.TimezoneName != cronTZ || spec.TimezoneData != nil {
193 return nil, errConflictingTimezoneNames
198
199 // validate structured calendar
200 > for _, structured := range spec.StructuredCalendar { spec.go
201 if err := validateStructuredCalendar(structured); err != nil {
202 return nil, err
205
206 // validate intervals
207 > for _, interval := range spec.Interval { spec.go
208 > if err := validateInterval(interval); err != nil { spec.go
209 return nil, err
210 }
211 }
212
213 > return spec, nil spec.go
214 }
215
253 }
254
255 > func validateInterval(i *schedulepb.IntervalSpec) error { spec.go
256 > if i == nil {
257 return errors.New("interval is nil")
258 }
259 // TODO: use timestamp.ValidateAndCapProtoDuration after switching to state machine based implementation.
260 // Not adding it to workflow based implementation to avoid potential non-determinism errors.
261 > iv, phase := timestamp.DurationValue(i.Interval), timestamp.DurationValue(i.Phase) spec.go
262 > if iv < time.Second {
263 return errors.New("interval is too small")
264 > } else if phase < 0 { spec.go
265 return errors.New("phase is negative")
266 > } else if phase >= iv { spec.go
267 return errors.New("phase cannot be greater than Interval")
268 }
269 > return nil spec.go
270 }
271
272 > func (b *SpecBuilder) loadTimezone(spec *schedulepb.ScheduleSpec) (*time.Location, error) { spec.go
273 > if spec.TimezoneData != nil {
274 return time.LoadLocationFromTZData(spec.TimezoneName, spec.TimezoneData)
275 }
276
277 > if cached, ok := b.locationCache.Get(spec.TimezoneName).(*locationAndError); ok { spec.go
278 return cached.loc, cached.err
279 }
280 > loc, err := time.LoadLocation(spec.TimezoneName) spec.go
281 > b.locationCache.Put(spec.TimezoneName, &locationAndError{
282 > loc: loc,
283 > err: err,
284 > })
285 > return loc, err
286 }
287
293 // Returns: Nominal is the time that matches, pre-jitter. Next is the nominal time with
294 // jitter applied. If there is no matching time, Nominal and Next will be the zero time.
295 > func (cs *CompiledSpec) GetNextTime(jitterSeed string, after time.Time) (GetNextTimeResult, error) { spec.go
296 > // If we're starting before the schedule's allowed time range, jump up to right before
297 > // it (so that we can still return the first second of the range if it happens to match).
298 > // note: AsTime returns unix epoch on nil StartTime
299 > after = util.MaxTime(after, cs.spec.StartTime.AsTime().Add(-time.Second))
300 >
301 > pastEndTime := func(t time.Time) bool {
302 > return cs.spec.EndTime != nil && t.After(cs.spec.EndTime.AsTime()) || t.Year() > maxCalendarYear spec.go
303 > }
304 > warnIterations := cs.warnIterations() spec.go
305 > if warnIterations <= 0 {
306 > warnIterations = DefaultWarnIterations spec.go
307 > }
308 > maxIterations := cs.maxIterations() spec.go
309 > if maxIterations <= 0 {
310 > maxIterations = math.MaxInt // disabled: effectively unlimited spec.go
311 > }
312
313 > var warned bool spec.go
314 > var nominal time.Time
315 > for iterations := 0; nominal.IsZero() || cs.excluded(nominal); iterations++ {
316 > // Hard bound: stop an over-excluded / adversarial spec from spinning toward
317 > // maxCalendarYear. Disabled by default (maxIterations == math.MaxInt); an operator can
318 > // lower it to re-enable enforcement. Well-formed specs resolve in a handful of iterations.
319 > if iterations >= maxIterations {
320 return GetNextTimeResult{ComputeLimitWarning: true}, ErrComputeLimitExceeded
321 }
322 > if iterations >= warnIterations { spec.go
323 warned = true
324 }
325 > nominal = cs.rawNextTime(after) spec.go
326 > after = nominal
327 >
328 > if nominal.IsZero() || pastEndTime(nominal) {
329 return GetNextTimeResult{ComputeLimitWarning: warned}, nil
330 }
331 }
332
333 > maxJitter := timestamp.DurationValue(cs.spec.Jitter) spec.go
334 > // Ensure that jitter doesn't push this time past the _next_ nominal start time
335 > if following := cs.rawNextTime(nominal); !following.IsZero() {
336 > maxJitter = min(maxJitter, following.Sub(nominal)) spec.go
337 > }
338 > next := cs.addJitter(jitterSeed, nominal, maxJitter) spec.go
339 >
340 > return GetNextTimeResult{Nominal: nominal, Next: next, ComputeLimitWarning: warned}, nil
341 }
342
343 // Returns the next matching time (without jitter), or the zero value if no time matches.
344 > func (cs *CompiledSpec) rawNextTime(after time.Time) (nominal time.Time) { spec.go
345 > var minTimestamp int64 = math.MaxInt64 // unix seconds-since-epoch as int64
346 >
347 > for _, cal := range cs.calendar {
348 if next := cal.next(after); !next.IsZero() {
349 nextTs := next.Unix()
354 }
355
356 > ts := after.Unix() spec.go
357 > for _, iv := range cs.spec.Interval {
358 > next := cs.nextIntervalTime(iv, ts) spec.go
359 > if next < minTimestamp {
360 > minTimestamp = next
361 > }
362 }
363
364 > if minTimestamp == math.MaxInt64 { spec.go
365 return time.Time{}
366 }
367 > return time.Unix(minTimestamp, 0).UTC() spec.go
368 }
369
370 // Returns the next matching time for a single interval spec.
371 > func (cs *CompiledSpec) nextIntervalTime(iv *schedulepb.IntervalSpec, ts int64) int64 { spec.go
372 > interval := max(int64(timestamp.DurationValue(iv.Interval)/time.Second), 1)
373 > phase := max(int64(timestamp.DurationValue(iv.Phase)/time.Second), 0)
374 > return (((ts-phase)/interval)+1)*interval + phase
375 > }
376
377 // Returns true if any exclude spec matches the time.
378 > func (cs *CompiledSpec) excluded(nominal time.Time) bool { spec.go
379 > for _, excal := range cs.excludes {
380 if excal.matches(nominal) {
381 return true
382 }
383 }
384 > return false spec.go
385 }
386
387 // Adds jitter to a nominal time, deterministically (by hashing the given time and a seed).
388 > func (cs *CompiledSpec) addJitter(seed string, nominal time.Time, maxJitter time.Duration) time.Time { spec.go
389 > if maxJitter < 0 {
390 maxJitter = 0
391 }
392
393 > bin, err := nominal.MarshalBinary() spec.go
394 > if err != nil {
395 return nominal
396 }
397
398 > bin = append(bin, []byte(seed)...) spec.go
399 >
400 > // we want to fit the result of a multiply in 64 bits, and use 32 bits of hash, which
401 > // leaves 32 bits for the range. if we use nanoseconds or microseconds, our range is
402 > // limited to only a few seconds or hours. using milliseconds supports up to 49 days.
403 > fp := uint64(farm.Fingerprint32(bin))
404 > ms := min(uint64(maxJitter.Milliseconds()), math.MaxUint32)
405 > jitter := time.Duration((fp*ms)>>32) * time.Millisecond
406 > return nominal.Add(jitter)
407 }
go.temporal.io/server/chasm/search_attribute.go 133 covered LOC · 20 ranges

Open complete file

136 }
137
138 > func newSearchAttributeFieldBool(index int) SearchAttributeFieldBool { search_attribute.go
139 > return SearchAttributeFieldBool{
140 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_BOOL, index),
141 > }
142 > }
143
144 // SearchAttributeFieldDateTime is a search attribute field for a datetime value.
147 }
148
149 > func newSearchAttributeFieldDateTime(index int) SearchAttributeFieldDateTime { search_attribute.go
150 > return SearchAttributeFieldDateTime{
151 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_DATETIME, index),
152 > }
153 > }
154
155 // SearchAttributeFieldInt is a search attribute field for an integer value.
158 }
159
160 > func newSearchAttributeFieldInt(index int) SearchAttributeFieldInt { search_attribute.go
161 > return SearchAttributeFieldInt{
162 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_INT, index),
163 > }
164 > }
165
166 // SearchAttributeFieldDouble is a search attribute field for a double value.
169 }
170
171 > func newSearchAttributeFieldDouble(index int) SearchAttributeFieldDouble { search_attribute.go
172 > return SearchAttributeFieldDouble{
173 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_DOUBLE, index),
174 > }
175 > }
176
177 // SearchAttributeFieldKeyword is a search attribute field for a keyword value.
180 }
181
182 > func newSearchAttributeFieldKeyword(index int) SearchAttributeFieldKeyword { search_attribute.go
183 > return SearchAttributeFieldKeyword{
184 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_KEYWORD, index),
185 > }
186 > }
187
188 > func newSearchAttributeFieldLowCardinalityKeyword(index int) SearchAttributeFieldKeyword { search_attribute.go
189 > return SearchAttributeFieldKeyword{
190 > field: fmt.Sprintf("%s%s%02d", sadefs.ReservedPrefix, "LowCardinalityKeyword", index),
191 > }
192 > }
193
194 // SearchAttributeFieldKeywordList is a search attribute field for a keyword list value.
197 }
198
199 > func newSearchAttributeFieldKeywordList(index int) SearchAttributeFieldKeywordList { search_attribute.go
200 > return SearchAttributeFieldKeywordList{
201 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, index),
202 > }
203 > }
204
205 // SearchAttributeFieldText is a search attribute field for a text value.
214 }
215
216 > func resolveFieldName(valueType enumspb.IndexedValueType, index int) string { search_attribute.go
217 > // Columns are named like TemporalBool01, TemporalDatetime01, TemporalDouble01, TemporalInt01.
218 > return fmt.Sprintf("%s%s%02d", sadefs.ReservedPrefix, valueType.String(), index)
219 > }
220
221 > func (s searchAttributeDefinition) definition() searchAttributeDefinition { search_attribute.go
222 > return s
223 > }
224
225 // SearchAttributeBool is a search attribute for a boolean value.
239 }
240
241 > func newSearchAttributeBoolByField(field string) SearchAttributeBool { search_attribute.go
242 > return SearchAttributeBool{
243 > searchAttributeDefinition: searchAttributeDefinition{
244 > alias: field,
245 > field: field,
246 > valueType: enumspb.INDEXED_VALUE_TYPE_BOOL,
247 > },
248 > }
249 > }
250
251 // Value sets the boolean value of the search attribute.
252 > func (s SearchAttributeBool) Value(value bool) SearchAttributeKeyValue { search_attribute.go
253 > return SearchAttributeKeyValue{
254 > Alias: s.alias,
255 > Field: s.field,
256 > Value: VisibilityValueBool(value),
257 > }
258 > }
259
260 func (s SearchAttributeBool) typeMarker(_ bool) {}
266
267 // NewSearchAttributeDateTime creates a new date time search attribute given a predefined chasm field
268 > func NewSearchAttributeDateTime(alias string, datetimeField SearchAttributeFieldDateTime) SearchAttributeDateTime { search_attribute.go
269 > return SearchAttributeDateTime{
270 > searchAttributeDefinition: searchAttributeDefinition{
271 > alias: alias,
272 > field: datetimeField.field,
273 > valueType: enumspb.INDEXED_VALUE_TYPE_DATETIME,
274 > },
275 > }
276 > }
277
278 > func newSearchAttributeDateTimeByField(field string) SearchAttributeDateTime { search_attribute.go
279 > return SearchAttributeDateTime{
280 > searchAttributeDefinition: searchAttributeDefinition{
281 > alias: field,
282 > field: field,
283 > valueType: enumspb.INDEXED_VALUE_TYPE_DATETIME,
284 > },
285 > }
286 > }
287
288 // Value sets the date time value of the search attribute.
289 > func (s SearchAttributeDateTime) Value(value time.Time) SearchAttributeKeyValue { search_attribute.go
290 > return SearchAttributeKeyValue{
291 > Alias: s.alias,
292 > Field: s.field,
293 > Value: VisibilityValueTime(value),
294 > }
295 > }
296
297 func (s SearchAttributeDateTime) typeMarker(_ time.Time) {}
303
304 // NewSearchAttributeInt creates a new integer search attribute given a predefined chasm field
305 > func NewSearchAttributeInt(alias string, intField SearchAttributeFieldInt) SearchAttributeInt { search_attribute.go
306 > return SearchAttributeInt{
307 > searchAttributeDefinition: searchAttributeDefinition{
308 > alias: alias,
309 > field: intField.field,
310 > valueType: enumspb.INDEXED_VALUE_TYPE_INT,
311 > },
312 > }
313 > }
314
315 // Value sets the integer value of the search attribute.
316 > func (s SearchAttributeInt) Value(value int64) SearchAttributeKeyValue { search_attribute.go
317 > return SearchAttributeKeyValue{
318 > Alias: s.alias,
319 > Field: s.field,
320 > Value: VisibilityValueInt64(value),
321 > }
322 > }
323
324 func (s SearchAttributeInt) typeMarker(_ int64) {}
367
368 // NewSearchAttributeKeyword creates a new keyword search attribute given a predefined chasm field
369 > func NewSearchAttributeKeyword(alias string, keywordField SearchAttributeFieldKeyword) SearchAttributeKeyword { search_attribute.go
370 > return SearchAttributeKeyword{
371 > searchAttributeDefinition: searchAttributeDefinition{
372 > alias: alias,
373 > field: keywordField.field,
374 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
375 > },
376 > }
377 > }
378
379 > func newSearchAttributeKeywordByField(field string) SearchAttributeKeyword { search_attribute.go
380 > return SearchAttributeKeyword{
381 > searchAttributeDefinition: searchAttributeDefinition{
382 > alias: field,
383 > field: field,
384 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
385 > },
386 > }
387 > }
388
389 // Value sets the string value of the search attribute.
390 > func (s SearchAttributeKeyword) Value(value string) SearchAttributeKeyValue { search_attribute.go
391 > return SearchAttributeKeyValue{
392 > Alias: s.alias,
393 > Field: s.field,
394 > Value: VisibilityValueKeyword(value),
395 > }
396 > }
397
398 func (s SearchAttributeKeyword) typeMarker(_ string) {}
414 }
415
416 > func newSearchAttributeKeywordListByField(field string) SearchAttributeKeywordList { search_attribute.go
417 > return SearchAttributeKeywordList{
418 > searchAttributeDefinition: searchAttributeDefinition{
419 > alias: field,
420 > field: field,
421 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
422 > },
423 > }
424 > }
425
426 // Value sets the string list value of the search attribute.
go.temporal.io/server/chasm/registry.go 118 covered LOC · 52 ranges

Open complete file

51 }
52
53 > func NewRegistry(logger log.Logger) *Registry { registry.go
54 > return &Registry{
55 > libraries: make(map[string]Library),
56 > rcByFqn: make(map[string]*RegistrableComponent),
57 > rcByID: make(map[uint32]*RegistrableComponent),
58 > rcByGoType: make(map[reflect.Type]*RegistrableComponent),
59 > rtByFqn: make(map[string]*RegistrableTask),
60 > rtByID: make(map[uint32]*RegistrableTask),
61 > rtByGoType: make(map[reflect.Type]*RegistrableTask),
62 > rcContextValues: make(map[any]valueWithFqn),
63 > nexusServices: make(map[string]*nexus.Service),
64 > NexusEndpointProcessor: NewNexusEndpointProcessor(),
65 > logger: logger,
66 > }
67 > }
68
69 > func (r *Registry) Register(lib Library) error { registry.go
70 > if err := r.validateName(lib.Name()); err != nil {
71 return err
72 }
73 > if _, ok := r.libraries[lib.Name()]; ok { registry.go
74 return fmt.Errorf("library %s is already registered", lib.Name())
75 }
76 > r.libraries[lib.Name()] = lib registry.go
77 >
78 > for _, c := range lib.Components() {
79 > if err := r.registerComponent(lib, c); err != nil { registry.go
80 return err
81 }
82 }
83 > for _, t := range lib.Tasks() { registry.go
84 > if err := r.registerTask(lib, t); err != nil { registry.go
85 return err
86 }
87 }
88
89 > for _, svc := range lib.NexusServices() { registry.go
90 if err := r.registerNexusService(svc); err != nil {
91 return err
93 }
94
95 > for _, svc := range lib.NexusServiceProcessors() { registry.go
96 if err := r.NexusEndpointProcessor.RegisterServiceProcessor(svc); err != nil {
97 return err
134 // This method should only be used by CHASM framework internal code,
135 // NOT CHASM library developers.
136 > func (r *Registry) ComponentByID(id uint32) (*RegistrableComponent, bool) { registry.go
137 > rc, ok := r.rcByID[id]
138 > return rc, ok
139 > }
140
141 // ComponentIDFor converts registered component instance to component type ID.
142 // This method should only be used by CHASM framework internal code,
143 // NOT CHASM library developers.
144 > func (r *Registry) ComponentIDFor(componentInstance any) (uint32, bool) { registry.go
145 > rc, ok := r.componentFor(componentInstance)
146 > if !ok {
147 return 0, false
148 }
149 > return rc.componentID, true registry.go
150 }
151
153 // This method should only be used by CHASM framework internal code,
154 // NOT CHASM library developers.
155 > func (r *Registry) TaskByID(id uint32) (*RegistrableTask, bool) { registry.go
156 > rt, ok := r.rtByID[id]
157 > return rt, ok
158 > }
159
160 // TaskFqnByID converts task type ID to fully qualified task type name.
183 // This method should only be used by CHASM framework internal code,
184 // NOT CHASM library developers.
185 > func (r *Registry) ArchetypeDisplayName(id ArchetypeID) (string, bool) { registry.go
186 > rc, ok := r.ComponentByID(id)
187 > if !ok {
188 return "", false
189 }
190 > return rc.componentType, true registry.go
191 }
192
212 }
213
214 > func (r *Registry) componentFor(componentInstance any) (*RegistrableComponent, bool) { registry.go
215 > rc, ok := r.rcByGoType[reflect.TypeOf(componentInstance)]
216 > return rc, ok
217 > }
218
219 > func (r *Registry) taskFor(taskInstance any) (*RegistrableTask, bool) { registry.go
220 > rt, ok := r.rtByGoType[reflect.TypeOf(taskInstance)]
221 > return rt, ok
222 > }
223
224 func (r *Registry) componentOf(componentGoType reflect.Type) (*RegistrableComponent, bool) {
235 lib namer,
236 rc *RegistrableComponent,
237 > ) error { registry.go
238 > if err := r.validate(rc); err != nil {
239 return err
240 }
241
242 > fqn, id, err := rc.registerToLibrary(lib) registry.go
243 > if err != nil {
244 return err
245 }
246
247 > if _, ok := r.rcByFqn[fqn]; ok { registry.go
248 return fmt.Errorf("component %s is already registered", fqn)
249 }
250
251 > if id == UnspecifiedArchetypeID { registry.go
252 return fmt.Errorf("component %s maps to a reserved archetype id %d, please use a different name", fqn, UnspecifiedArchetypeID)
253 }
254
255 > if existingComponent, ok := r.rcByID[id]; ok { registry.go
256 return fmt.Errorf("component ID %d collision between %s and %s", id, fqn, existingComponent.fqType())
257 }
258
259 > for key, value := range rc.contextValues { registry.go
260 > if existingValue, ok := r.rcContextValues[key]; ok { registry.go
261 return fmt.Errorf("context value key %v registered by component %s conflicts with component %s", key, fqn, existingValue.fqn)
262 }
263 > r.rcContextValues[key] = valueWithFqn{ registry.go
264 > v: value,
265 > fqn: fqn,
266 > }
267 }
268
269 // rc.goType implements Component interface; therefore, it must be a struct.
270 // This check to protect against the interface itself being registered.
271 > if !(rc.goType.Kind() == reflect.Struct || registry.go
272 > (rc.goType.Kind() == reflect.Pointer && rc.goType.Elem().Kind() == reflect.Struct)) {
273 return fmt.Errorf("component type %s must be struct or pointer to struct", rc.goType.String())
274 }
275 > if _, ok := r.rcByGoType[rc.goType]; ok { registry.go
276 return fmt.Errorf("component type %s is already registered", rc.goType.String())
277 }
278 > r.warnUnmanagedFields(fqn, rc) registry.go
279 >
280 > r.rcByFqn[fqn] = rc
281 > r.rcByID[id] = rc
282 > r.rcByGoType[rc.goType] = rc
283 > return nil
284 }
285
286 > func (r *Registry) validate(rc *RegistrableComponent) error { registry.go
287 > if err := r.validateName(rc.componentType); err != nil {
288 return err
289 }
290 > return r.validateVisibilityBusinessIDAlias(rc) registry.go
291 }
292
294 lib namer,
295 rt *RegistrableTask,
296 > ) error { registry.go
297 > if err := r.validateName(rt.taskType); err != nil {
298 return err
299 }
300
301 > fqn, id, err := rt.registerToLibrary(lib) registry.go
302 > if err != nil {
303 return err
304 }
305
306 > if _, ok := r.rtByFqn[fqn]; ok { registry.go
307 return fmt.Errorf("task %s is already registered", fqn)
308 }
309
310 > if existingTask, ok := r.rtByID[id]; ok { registry.go
311 return fmt.Errorf("task type ID %d collision between %s and %s", id, fqn, existingTask.fqType())
312 }
313
314 > if !(rt.goType.Kind() == reflect.Struct || registry.go
315 > (rt.goType.Kind() == reflect.Pointer && rt.goType.Elem().Kind() == reflect.Struct)) {
316 return fmt.Errorf("task type %s must be struct or pointer to struct", rt.goType.String())
317 }
318 > if _, ok := r.rtByGoType[rt.goType]; ok { registry.go
319 return fmt.Errorf("task type %s is already registered", rt.goType.String())
320 }
321 > if !(rt.componentGoType.Kind() == reflect.Interface || registry.go
322 > (rt.componentGoType.Kind() == reflect.Struct ||
323 > (rt.componentGoType.Kind() == reflect.Pointer && rt.componentGoType.Elem().Kind() == reflect.Struct)) &&
324 > rt.componentGoType.AssignableTo(reflect.TypeFor[Component]())) {
325 return fmt.Errorf("component type %s must be and interface or struct that implements Component interface", rt.componentGoType.String())
326 }
327
328 > r.rtByFqn[fqn] = rt registry.go
329 > r.rtByID[id] = rt
330 > r.rtByGoType[rt.goType] = rt
331 > return nil
332 }
333
334 > func (r *Registry) validateName(n string) error { registry.go
335 > if n == "" {
336 return errors.New("name must not be empty")
337 }
338 > if !nameValidator.MatchString(n) { registry.go
339 return fmt.Errorf("name %s is invalid. name must follow golang identifier rules: %s", n, nameValidator.String())
340 }
341 > return nil registry.go
342 }
343
344 > func (r *Registry) validateVisibilityBusinessIDAlias(rc *RegistrableComponent) error { registry.go
345 > if !hasVisibilityField(rc.goType) {
346 > return nil registry.go
347 > }
348 // Archetypes that contain a Field[*Visibility] must specify WithBusinessIDAlias.
349 > if !rc.hasBusinessIDAlias() { registry.go
350 return fmt.Errorf("component %s has Field[*Visibility] but no businessID alias; use WithBusinessIDAlias option", rc.componentType)
351 }
352 > return nil registry.go
353 }
354
355 > func (r *Registry) warnUnmanagedFields(fqn string, rc *RegistrableComponent) { registry.go
356 > var unmanagedFields []string
357 > for f := range unmanagedFieldsOf(rc.goType) {
358 > unmanagedFields = append(unmanagedFields, fmt.Sprintf("%s %s", f.name, f.typ)) registry.go
359 > }
360 > if len(unmanagedFields) > 0 { registry.go
361 > r.logger.Info(fmt.Sprintf( registry.go
362 > "Warning: CHASM component %s declares state fields that won't be managed by CHASM:\n\t%s",
363 > fqn,
364 > strings.Join(unmanagedFields, "\n\t")))
365 > }
366 }
367
382 }
383
384 > func (r *Registry) componentContextValue(key any) any { registry.go
385 > if v, ok := r.rcContextValues[key]; ok {
386 > return v.v registry.go
387 > }
388 return nil
389 }
go.temporal.io/server/common/testing/testlogger/testlogger.go 107 covered LOC · 22 ranges

Open complete file

235 )
236
237 > func getGlobalFileCore() zapcore.Core { testlogger.go
238 > globalFileCoreOnce.Do(func() {
239 > logFile := os.Getenv(log.TestLogFileEnvVar)
240 > if logFile == "" {
241 return
242 }
243 > if err := os.MkdirAll(filepath.Dir(logFile), 0o755); err != nil { testlogger.go
244 fmt.Fprintf(os.Stderr, "testlogger: failed to create log file dir %s: %v\n", filepath.Dir(logFile), err)
245 return
246 }
247 > f, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) testlogger.go
248 > if err != nil {
249 fmt.Fprintf(os.Stderr, "testlogger: failed to open log file %s: %v\n", logFile, err)
250 return
251 }
252 > format := cmp.Or(os.Getenv(log.TestLogFileFormatEnvVar), "json") testlogger.go
253 > var enc zapcore.Encoder
254 > switch strings.ToLower(format) {
255 case "console":
256 enc = zapcore.NewConsoleEncoder(log.DefaultZapEncoderConfig)
257 > default: // "json" and anything unrecognized testlogger.go
258 > enc = zapcore.NewJSONEncoder(log.DefaultZapEncoderConfig)
259 }
260 > level := zapcore.DebugLevel testlogger.go
261 > if levelV := os.Getenv(log.TestLogFileLevelEnvVar); levelV != "" {
262 level = log.ParseZapLevel(levelV)
263 }
264 > globalFileCore = zapcore.NewCore(enc, zapcore.AddSync(f), level) testlogger.go
265 > fmt.Fprintf(os.Stderr, "testlogger: file logging enabled → %s (format=%s level=%s)\n", logFile, format, level)
266 })
267 > return globalFileCore testlogger.go
268 }
269
270 // NewTestLogger creates a new TestLogger that logs to the provided testing.T.
271 // Mode controls the behavior of the logger for when an expected or unexpected error is encountered.
272 > func NewTestLogger(t TestingT, mode Mode, opts ...LoggerOption) *TestLogger { testlogger.go
273 > tl := &TestLogger{
274 > state: &sharedTestLoggerState{
275 > t: t,
276 > logExpectations: false,
277 > level: zapcore.DebugLevel,
278 > logCaller: true,
279 > mode: mode,
280 > },
281 > }
282 > tl.state.mu.expectations = make(map[Level]*list.List)
283 > tl.state.failOnError.Store(true)
284 > tl.state.failOnDPanic.Store(true)
285 > tl.state.failOnFatal.Store(true)
286 > for _, opt := range opts {
287 opt(tl)
288 }
289 > if tl.wrapped == nil { testlogger.go
290 > writer := zaptest.NewTestingWriter(t)
291 >
292 > // Console core: format and level controlled by TEMPORAL_TEST_LOG_FORMAT / TEMPORAL_TEST_LOG_LEVEL.
293 > var consoleEnc zapcore.Encoder
294 > format := cmp.Or(os.Getenv(log.TestLogFormatEnvVar), "console")
295 > switch strings.ToLower(format) {
296 > case "console":
297 > consoleEnc = zapcore.NewConsoleEncoder(log.DefaultZapEncoderConfig)
298 case "json":
299 consoleEnc = zapcore.NewJSONEncoder(log.DefaultZapEncoderConfig)
301 t.Fatalf("unknown log encoding %q", format)
302 }
303 > consoleLevel := tl.state.level testlogger.go
304 > if levelV := os.Getenv(log.TestLogLevelEnvVar); levelV != "" {
305 consoleLevel = log.ParseZapLevel(levelV)
306 }
307 > core := zapcore.NewTee( testlogger.go
308 > zapcore.NewCore(consoleEnc, writer, consoleLevel),
309 > getGlobalFileCore())
310 >
311 > zapOptions := []zap.Option{
312 > zap.ErrorOutput(writer.WithMarkFailed(true)),
313 > zap.AddStacktrace(zap.ErrorLevel), // only include stack traces for logs with level error and above
314 > zap.WithCaller(tl.state.logCaller),
315 > }
316 >
317 > // Skip(1) skips the TestLogger itself
318 > tl.wrapped = log.NewZapLogger(zap.New(core, zapOptions...)).Skip(1)
319 }
320
321 // Only possible with a *testing.T until *rapid.T supports `Cleanup`
322 > if ct, ok := t.(CleanupCapableT); ok { testlogger.go
323 > // NOTE(tim): We don't care about anything logged after the test completes. Sure, this is racy,
324 > // but it reduces the likelihood that we see stupid errors due to testing.T.Logf race conditions...
325 > ct.Cleanup(tl.Close)
326 > }
327
328 > return tl testlogger.go
329 }
330
385 // observational: it never affects whether the test fails (that remains the sole
386 // job of shouldFailTest), so it is safe to call for any log at any level.
387 > func (tl *TestLogger) recordExpectationMatches(level Level, msg string, tags []tag.Tag) { testlogger.go
388 > expectations, found := tl.state.mu.expectations[level]
389 > if !found {
390 > return testlogger.go
391 > }
392 for e := expectations.Front(); e != nil; e = e.Next() {
393 m, ok := e.Value.(matcher)
444 }
445
446 > func (tl *TestLogger) mergeWithLoggerTags(tags []tag.Tag) []tag.Tag { testlogger.go
447 > if len(tl.tags) == 0 {
448 > return tags
449 > }
450 > tagMap := make(map[string]tag.Tag, len(tl.tags)+len(tags)) testlogger.go
451 > // Iterate over the logger's tags first so that explicitly specified tags override them
452 > for _, t := range tl.tags {
453 > tagMap[t.Key()] = t
454 > }
455 > for _, t := range tags {
456 > tagMap[t.Key()] = t
457 > }
458 > newTags := make([]tag.Tag, 0, len(tagMap))
459 > for _, t := range tagMap {
460 > newTags = append(newTags, t)
461 > }
462 > slices.SortStableFunc(newTags, func(a, b tag.Tag) int {
463 > return cmp.Compare(a.Key(), b.Key())
464 > })
465 > return newTags
466 }
467
545
546 // Info implements log.Logger.
547 > func (tl *TestLogger) Info(msg string, tags ...tag.Tag) { testlogger.go
548 > tl.state.mu.RLock()
549 > defer tl.state.mu.RUnlock()
550 > if tl.state.mu.closed {
551 return
552 }
553 > tags = tl.mergeWithLoggerTags(tags) testlogger.go
554 > tl.recordExpectationMatches(Info, msg, tags)
555 > tl.wrapped.Info(msg, tags...)
556 }
557
635 // Close disallows any further logging, preventing the test framework from complaining about
636 // logging post-test.
637 > func (tl *TestLogger) Close() { testlogger.go
638 > // Taking the write lock ensures all in-progress log calls complete before we close.
639 > // This prevents a race condition after the test has completed.
640 > tl.state.mu.Lock()
641 > tl.state.mu.closed = true
642 > tl.state.mu.Unlock()
643 > }
644
645 func (tl *TestLogger) T() TestingT {
650
651 // With implements log.WithLogger
652 > func (tl *TestLogger) With(tags ...tag.Tag) log.Logger { testlogger.go
653 > return &TestLogger{
654 > wrapped: tl.wrapped,
655 > state: tl.state,
656 > tags: tl.mergeWithLoggerTags(tags),
657 > }
658 > }
659
660 // Format the log.Logger tags and such into a useful message
go.temporal.io/server/chasm/lib/scheduler/generator_tasks.go 89 covered LOC · 15 ranges

Open complete file

38 )
39
40 > func NewGeneratorTaskHandler(opts GeneratorTaskHandlerOptions) *GeneratorTaskHandler { generator_tasks.go
41 > return &GeneratorTaskHandler{
42 > config: opts.Config,
43 > metricsHandler: opts.MetricsHandler,
44 > baseLogger: opts.BaseLogger,
45 > SpecProcessor: opts.SpecProcessor,
46 > specBuilder: opts.SpecBuilder,
47 > }
48 > }
49
50 func (g *GeneratorTaskHandler) Execute(
53 _ chasm.TaskAttributes,
54 _ *schedulerpb.GeneratorTask,
55 > ) error { generator_tasks.go
56 > scheduler := generator.Scheduler.Get(ctx)
57 > logger := newTaggedLogger(g.baseLogger, scheduler)
58 > metricsHandler := newTaggedMetricsHandler(g.metricsHandler, scheduler)
59 > invoker := scheduler.Invoker.Get(ctx)
60 >
61 > now := ctx.Now(generator)
62 >
63 > generator.getOrCreateEventLog(ctx).LogEvent(ctx, "generatorTask executed")
64 >
65 > // If we have no last processed time, this is a new schedule.
66 > if generator.LastProcessedTime == nil {
67 > createdAt := timestamppb.New(now) generator_tasks.go
68 > generator.LastProcessedTime = createdAt
69 > scheduler.Info.CreateTime = createdAt
70 >
71 > g.logSchedule(ctx, logger, "starting schedule", generator, scheduler)
72 > }
73
74 // If the high water mark is earlier than when a schedule was updated, we must skip any actions that hadn't
75 // yet been processed.
76 > if scheduler.Info.GetUpdateTime().AsTime().After(generator.LastProcessedTime.AsTime()) { generator_tasks.go
77 generator.LastProcessedTime = scheduler.Info.GetUpdateTime()
78 }
79
80 // Process time range between last high water mark and system time.
81 > t1 := generator.LastProcessedTime.AsTime() generator_tasks.go
82 > t2 := now.UTC()
83 > if t2.Before(t1) {
84 logger.Error("time went backwards",
85 tag.Stringer("time", t1),
88 }
89
90 > tweakables := g.config.Tweakables(scheduler.Namespace) generator_tasks.go
91 > var limit *int
92 > if tweakables.MaxBufferSize > 0 {
93 > remaining := tweakables.MaxBufferSize - len(invoker.GetBufferedStarts())
94 > limit = &remaining
95 > }
96
97 // Generate BufferedStarts and determine the next HWM. Actions are skipped when
98 // they can't be taken (paused, or limited and without any remaining actions),
99 // and dropped when the buffer is full.
100 > result, err := g.SpecProcessor.ProcessTimeRange( generator_tasks.go
101 > scheduler,
102 > t1, t2,
103 > scheduler.overlapPolicy(),
104 > scheduler.WorkflowID(),
105 > "",
106 > false,
107 > limit,
108 > )
109 > if err != nil {
110 // An error here should be impossible, send to the DLQ.
111 return queueerrors.NewUnprocessableTaskError(
113 }
114
115 > if result.DroppedCount > 0 { generator_tasks.go
116 // Only system log on the first drop, as it's likely that a case that overruns
117 // will continue to overrun.
130 // to paused schedules vs. real work. Each fire while paused advances the
131 // HWM without buffering anything.
132 > metricsHandler.Counter(metrics.ScheduleGeneratorTicks.Name()).Record(1) generator_tasks.go
133 > if scheduler.Schedule.State.Paused {
134 metricsHandler.Counter(metrics.ScheduleGeneratorPausedTicks.Name()).Record(1)
135 }
136
137 // Enqueue newly-generated buffered starts.
138 > if len(result.BufferedStarts) > 0 { generator_tasks.go
139 invoker.EnqueueBufferedStarts(ctx, result.BufferedStarts)
140 }
141
142 // Write the new high water mark and future action times.
143 > generator.LastProcessedTime = timestamppb.New(result.LastActionTime) generator_tasks.go
144 > generator.UpdateFutureActionTimes(ctx, g.specBuilder)
145 >
146 > // Schedule the next timer task. Three outcomes are possible:
147 > // - isIdle: the schedule is done; arm the idle task to close it.
148 > // - NextWakeupTime is set: arm the next generator tick.
149 > // - Neither: Hold open without a task. This requires both that
150 > // isHeldOpen is true (paused or backfill pending) AND that no spec
151 > // wakeup is available, e.g. a paused manual-only schedule. IdleTime=0
152 > // also lands here. An external trigger (Patch.Unpause, Update, or a
153 > // BackfillerTask's completion-time Generate call) revives us.
154 > idleTimeTotal := tweakables.IdleTime
155 > idleExpiration, isIdle := scheduler.getIdleExpiration(ctx, idleTimeTotal, result.NextWakeupTime)
156 > if isIdle {
157 // Schedule is complete, no need for another buffer task. We keep the schedule's
158 // backing mutable state explicitly open for the idle period, during which the
176 // Not idle: the schedule has work again (or is being held open), so it's
177 // no longer pending an idle close.
178 > scheduler.IdleCloseTime = nil generator_tasks.go
179 >
180 > if !result.NextWakeupTime.IsZero() {
181 > // Keep the generator task perpetually scheduled. When paused, the next
182 > // fire will simply advance the HWM without appending actions (handled in
183 > // ProcessTimeRange).
184 > generator.scheduleTask(ctx, result.NextWakeupTime)
185 > } else {
186 // Hold open without a task: see the comment block above.
187 metricsHandler.Counter(metrics.SchedulerGeneratorLoopCompleted.Name()).Record(1)
188 }
189
190 > return nil generator_tasks.go
191 }
192
193 > func (g *GeneratorTaskHandler) logSchedule(ctx chasm.MutableContext, logger log.Logger, msg string, generator *Generator, sched *Scheduler) { generator_tasks.go
194 > spec := jsonStringer{sched.Schedule.Spec}
195 > policies := jsonStringer{sched.Schedule.Policies}
196 >
197 > generator.getOrCreateEventLog(ctx).LogEvent(ctx, fmt.Sprintf("%s:\nSpec: %s\nPolicies: %s\n", msg, spec, policies))
198 > logger.Info(msg,
199 > tag.Stringer("spec", spec),
200 > tag.Stringer("policies", policies))
201 > }
202
203 func (g *GeneratorTaskHandler) Validate(
206 attrs chasm.TaskInvocation,
207 _ *schedulerpb.GeneratorTask,
208 > ) (bool, error) { generator_tasks.go
209 > return validateTaskHighWaterMark(
210 > generator.GetLastProcessedTime(),
211 > attrs.ScheduledTime,
212 > )
213 > }
go.temporal.io/server/common/cache/lru.go 89 covered LOC · 25 ranges

Open complete file

135
136 // New creates a new cache with the given options
137 > func New(maxSize int, opts *Options) StoppableCache { lru.go
138 > return NewWithMetrics(maxSize, opts, metrics.NoopMetricsHandler)
139 > }
140
141 // NewWithMetrics creates a new cache that will emit capacity and ttl metrics.
142 // handler should be tagged with metrics.CacheTypeTag.
143 > func NewWithMetrics(maxSize int, opts *Options, handler metrics.Handler) StoppableCache { lru.go
144 > if opts == nil {
145 opts = &Options{}
146 }
147
148 > backgroundEvict := opts.BackgroundEvict lru.go
149 > if backgroundEvict == nil {
150 > backgroundEvict = func() dynamicconfig.CacheBackgroundEvictSettings { lru.go
151 > return dynamicconfig.CacheBackgroundEvictSettings{
152 > Enabled: false,
153 > }
154 > }
155 }
156
157 > timeSource := opts.TimeSource lru.go
158 > if timeSource == nil {
159 > timeSource = clock.NewRealTimeSource() lru.go
160 > }
161
162 > metrics.CacheSize.With(handler).Record(float64(maxSize)) lru.go
163 > metrics.CacheTtl.With(handler).Record(opts.TTL)
164 > c := &lru{
165 > byAccess: list.New(),
166 > byKey: make(map[any]*list.Element),
167 > ttl: opts.TTL,
168 > maxSize: maxSize,
169 > currSize: 0,
170 > pin: opts.Pin,
171 > onPut: opts.OnPut,
172 > onEvict: opts.OnEvict,
173 > timeSource: timeSource,
174 > metricsHandler: handler,
175 > backgroundEvict: backgroundEvict,
176 > }
177 > if c.backgroundEvict().Enabled {
178 c.loops.Go(c.bgEvictLoop)
179 }
180 > return c lru.go
181 }
182
188
189 // Get retrieves the value stored under the given key
190 > func (c *lru) Get(key any) any { lru.go
191 > if c.maxSize == 0 { //
192 return nil
193 }
194 > c.mut.Lock() lru.go
195 > defer c.mut.Unlock()
196 >
197 > element := c.byKey[key]
198 > if element == nil {
199 > return nil lru.go
200 > }
201
202 entry := element.Value.(*entryImpl)
216
217 // Put puts a new value associated with a given key, returning the existing value (if present)
218 > func (c *lru) Put(key any, value any) any { lru.go
219 > if c.pin {
220 panic("Cannot use Put API in Pin mode. Use Delete and PutIfNotExist if necessary")
221 }
222 > val, _ := c.putInternal(key, value, true) lru.go
223 > return val
224 }
225
294 // Put puts a new value associated with a given key, returning the existing value (if present)
295 // allowUpdate flag is used to control overwrite behavior if the value exists.
296 > func (c *lru) putInternal(key any, value any, allowUpdate bool) (any, error) { lru.go
297 > if c.maxSize == 0 {
298 return nil, nil
299 }
300 > newEntrySize := getSize(value) lru.go
301 > if newEntrySize > c.maxSize {
302 return nil, ErrCacheItemTooLarge
303 }
304
305 > c.mut.Lock() lru.go
306 > defer c.mut.Unlock()
307 >
308 > elt := c.byKey[key]
309 > // If the entry exists, check if it has expired or update the value
310 > if elt != nil {
311 existingEntry := elt.Value.(*entryImpl)
312 if !c.isEntryExpired(existingEntry, c.timeSource.Now().UTC()) {
347 }
348
349 > c.tryEvictUntilEnoughSpaceWithSkipEntry(newEntrySize, nil) lru.go
350 >
351 > // check if the new entry can fit in the cache
352 > newCacheSize := c.calculateNewCacheSize(newEntrySize, emptyEntrySize)
353 > if newCacheSize > c.maxSize {
354 return nil, ErrCacheFull
355 }
356
357 > entry := &entryImpl{ lru.go
358 > key: key,
359 > value: value,
360 > size: newEntrySize,
361 > }
362 > c.updateEntryTTL(entry)
363 > c.updateEntryRefCount(entry)
364 > element := c.byAccess.PushFront(entry)
365 > c.byKey[key] = element
366 > c.currSize = newCacheSize
367 > metrics.CacheUsage.With(c.metricsHandler).Record(float64(c.currSize))
368 >
369 > if c.onPut != nil {
370 c.onPut(value)
371 }
372
373 > return nil, nil lru.go
374 }
375
376 > func (c *lru) calculateNewCacheSize(newEntrySize int, existingEntrySize int) int { lru.go
377 > return c.currSize - existingEntrySize + newEntrySize
378 > }
379
380 func (c *lru) deleteInternal(element *list.Element) {
397 // tryEvictUntilEnoughSpaceWithSkipEntry try to evict entries until there is enough space for the new entry without
398 // evicting the existing entry. the existing entry is skipped because it is being updated.
399 > func (c *lru) tryEvictUntilEnoughSpaceWithSkipEntry(newEntrySize int, existingEntry *entryImpl) { lru.go
400 > element := c.byAccess.Back()
401 > existingEntrySize := 0
402 > if existingEntry != nil {
403 existingEntrySize = existingEntry.Size()
404 }
405
406 > for c.calculateNewCacheSize(newEntrySize, existingEntrySize) > c.maxSize && element != nil { lru.go
407 entry := element.Value.(*entryImpl)
408 if existingEntry != nil && entry.key == existingEntry.key {
430 }
431
432 > func (c *lru) updateEntryTTL(entry *entryImpl) { lru.go
433 > if c.ttl != 0 {
434 > entry.createTime = c.timeSource.Now().UTC() lru.go
435 > }
436 }
437
438 > func (c *lru) updateEntryRefCount(entry *entryImpl) { lru.go
439 > if c.pin {
440 entry.refCount++
441 if entry.refCount == 1 {
go.temporal.io/server/api/persistence/v1/predicates.pb.go 82 covered LOC · 22 ranges

Open complete file

57 func (*Predicate) ProtoMessage() {}
58
59 > func (x *Predicate) ProtoReflect() protoreflect.Message { predicates.pb.go
60 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[0]
61 > if x != nil {
62 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
63 > if ms.LoadMessageInfo() == nil {
64 > ms.StoreMessageInfo(mi)
65 > }
66 > return ms
67 }
68 return mi.MessageOf(x)
261 func (*UniversalPredicateAttributes) ProtoMessage() {}
262
263 > func (x *UniversalPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
264 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[1]
265 > if x != nil {
266 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
267 if ms.LoadMessageInfo() == nil {
297 func (*EmptyPredicateAttributes) ProtoMessage() {}
298
299 > func (x *EmptyPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
300 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[2]
301 > if x != nil {
302 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
303 if ms.LoadMessageInfo() == nil {
334 func (*AndPredicateAttributes) ProtoMessage() {}
335
336 > func (x *AndPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
337 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[3]
338 > if x != nil {
339 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
340 if ms.LoadMessageInfo() == nil {
378 func (*OrPredicateAttributes) ProtoMessage() {}
379
380 > func (x *OrPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
381 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[4]
382 > if x != nil {
383 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
384 if ms.LoadMessageInfo() == nil {
422 func (*NotPredicateAttributes) ProtoMessage() {}
423
424 > func (x *NotPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
425 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[5]
426 > if x != nil {
427 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
428 if ms.LoadMessageInfo() == nil {
466 func (*NamespaceIdPredicateAttributes) ProtoMessage() {}
467
468 > func (x *NamespaceIdPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
469 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[6]
470 > if x != nil {
471 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
472 if ms.LoadMessageInfo() == nil {
510 func (*TaskTypePredicateAttributes) ProtoMessage() {}
511
512 > func (x *TaskTypePredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
513 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[7]
514 > if x != nil {
515 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
516 if ms.LoadMessageInfo() == nil {
554 func (*DestinationPredicateAttributes) ProtoMessage() {}
555
556 > func (x *DestinationPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
557 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[8]
558 > if x != nil {
559 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
560 if ms.LoadMessageInfo() == nil {
598 func (*OutboundTaskGroupPredicateAttributes) ProtoMessage() {}
599
600 > func (x *OutboundTaskGroupPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
601 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[9]
602 > if x != nil {
603 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
604 if ms.LoadMessageInfo() == nil {
642 func (*OutboundTaskPredicateAttributes) ProtoMessage() {}
643
644 > func (x *OutboundTaskPredicateAttributes) ProtoReflect() protoreflect.Message { predicates.pb.go
645 > mi := &file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[10]
646 > if x != nil {
647 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
648 if ms.LoadMessageInfo() == nil {
828 }
829
830 > func init() { file_temporal_server_api_persistence_v1_predicates_proto_init() } predicates.pb.go
831 > func file_temporal_server_api_persistence_v1_predicates_proto_init() {
832 > if File_temporal_server_api_persistence_v1_predicates_proto != nil {
833 > return
834 > }
835 > file_temporal_server_api_persistence_v1_predicates_proto_msgTypes[0].OneofWrappers = []any{
836 > (*Predicate_UniversalPredicateAttributes)(nil),
837 > (*Predicate_EmptyPredicateAttributes)(nil),
838 > (*Predicate_AndPredicateAttributes)(nil),
839 > (*Predicate_OrPredicateAttributes)(nil),
840 > (*Predicate_NotPredicateAttributes)(nil),
841 > (*Predicate_NamespaceIdPredicateAttributes)(nil),
842 > (*Predicate_TaskTypePredicateAttributes)(nil),
843 > (*Predicate_DestinationPredicateAttributes)(nil),
844 > (*Predicate_OutboundTaskGroupPredicateAttributes)(nil),
845 > (*Predicate_OutboundTaskPredicateAttributes)(nil),
846 > }
847 > type x struct{}
848 > out := protoimpl.TypeBuilder{
849 > File: protoimpl.DescBuilder{
850 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
851 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_predicates_proto_rawDesc), len(file_temporal_server_api_persistence_v1_predicates_proto_rawDesc)),
852 > NumEnums: 0,
853 > NumMessages: 12,
854 > NumExtensions: 0,
855 > NumServices: 0,
856 > },
857 > GoTypes: file_temporal_server_api_persistence_v1_predicates_proto_goTypes,
858 > DependencyIndexes: file_temporal_server_api_persistence_v1_predicates_proto_depIdxs,
859 > MessageInfos: file_temporal_server_api_persistence_v1_predicates_proto_msgTypes,
860 > }.Build()
861 > File_temporal_server_api_persistence_v1_predicates_proto = out.File
862 > file_temporal_server_api_persistence_v1_predicates_proto_goTypes = nil
863 > file_temporal_server_api_persistence_v1_predicates_proto_depIdxs = nil
864 }
go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/message.pb.go 82 covered LOC · 13 ranges

Open complete file

72 func (*SchedulerState) ProtoMessage() {}
73
74 > func (x *SchedulerState) ProtoReflect() protoreflect.Message { message.pb.go
75 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[0]
76 > if x != nil {
77 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
78 > if ms.LoadMessageInfo() == nil {
79 > ms.StoreMessageInfo(mi)
80 > }
81 > return ms
82 }
83 return mi.MessageOf(x)
184 func (*WorkflowMigrationState) ProtoMessage() {}
185
186 > func (x *WorkflowMigrationState) ProtoReflect() protoreflect.Message { message.pb.go
187 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[1]
188 > if x != nil {
189 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
190 if ms.LoadMessageInfo() == nil {
193 return ms
194 }
195 > return mi.MessageOf(x) message.pb.go
196 }
197
239 func (*GeneratorState) ProtoMessage() {}
240
241 > func (x *GeneratorState) ProtoReflect() protoreflect.Message { message.pb.go
242 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[2]
243 > if x != nil {
244 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
245 > if ms.LoadMessageInfo() == nil {
246 > ms.StoreMessageInfo(mi)
247 > }
248 > return ms
249 }
250 return mi.MessageOf(x)
256 }
257
258 > func (x *GeneratorState) GetLastProcessedTime() *timestamppb.Timestamp { message.pb.go
259 > if x != nil {
260 > return x.LastProcessedTime
261 > }
262 return nil
263 }
302 func (*InvokerState) ProtoMessage() {}
303
304 > func (x *InvokerState) ProtoReflect() protoreflect.Message { message.pb.go
305 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[3]
306 > if x != nil {
307 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
308 > if ms.LoadMessageInfo() == nil {
309 > ms.StoreMessageInfo(mi)
310 > }
311 > return ms
312 }
313 return mi.MessageOf(x)
319 }
320
321 > func (x *InvokerState) GetBufferedStarts() []*v11.BufferedStart { message.pb.go
322 > if x != nil {
323 > return x.BufferedStarts
324 > }
325 return nil
326 }
484 func (*LastCompletionResult) ProtoMessage() {}
485
486 > func (x *LastCompletionResult) ProtoReflect() protoreflect.Message { message.pb.go
487 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[5]
488 > if x != nil {
489 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) message.pb.go
490 > if ms.LoadMessageInfo() == nil {
491 > ms.StoreMessageInfo(mi)
492 > }
493 > return ms
494 }
495 return mi.MessageOf(x)
633 func (*EventLog) ProtoMessage() {}
634
635 > func (x *EventLog) ProtoReflect() protoreflect.Message { message.pb.go
636 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[7]
637 > if x != nil {
638 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
639 > if ms.LoadMessageInfo() == nil {
640 > ms.StoreMessageInfo(mi)
641 > }
642 > return ms
643 }
644 return mi.MessageOf(x)
678 func (*Event) ProtoMessage() {}
679
680 > func (x *Event) ProtoReflect() protoreflect.Message { message.pb.go
681 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[8]
682 > if x != nil {
683 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
684 if ms.LoadMessageInfo() == nil {
687 return ms
688 }
689 > return mi.MessageOf(x) message.pb.go
690 }
691
843 }
844
845 > func init() { file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_init() } message.pb.go
846 > func file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_init() {
847 > if File_temporal_server_chasm_lib_scheduler_proto_v1_message_proto != nil {
848 > return
849 > }
850 > file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes[4].OneofWrappers = []any{
851 > (*BackfillerState_BackfillRequest)(nil),
852 > (*BackfillerState_TriggerRequest)(nil),
853 > }
854 > type x struct{}
855 > out := protoimpl.TypeBuilder{
856 > File: protoimpl.DescBuilder{
857 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
858 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_rawDesc), len(file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_rawDesc)),
859 > NumEnums: 0,
860 > NumMessages: 12,
861 > NumExtensions: 0,
862 > NumServices: 0,
863 > },
864 > GoTypes: file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_goTypes,
865 > DependencyIndexes: file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_depIdxs,
866 > MessageInfos: file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_msgTypes,
867 > }.Build()
868 > File_temporal_server_chasm_lib_scheduler_proto_v1_message_proto = out.File
869 > file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_goTypes = nil
870 > file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_depIdxs = nil
871 }
go.temporal.io/server/api/persistence/v1/chasm.pb.go 76 covered LOC · 17 ranges

Open complete file

67 }
68
69 > func (x *ChasmNode) GetMetadata() *ChasmNodeMetadata { chasm.pb.go
70 > if x != nil {
71 > return x.Metadata
72 > }
73 return nil
74 }
135 }
136
137 > func (x *ChasmNodeMetadata) GetLastUpdateVersionedTransition() *VersionedTransition { chasm.pb.go
138 > if x != nil {
139 > return x.LastUpdateVersionedTransition
140 > }
141 return nil
142 }
143
144 > func (x *ChasmNodeMetadata) GetAttributes() isChasmNodeMetadata_Attributes { chasm.pb.go
145 > if x != nil {
146 > return x.Attributes
147 > }
148 return nil
149 }
150
151 > func (x *ChasmNodeMetadata) GetComponentAttributes() *ChasmComponentAttributes { chasm.pb.go
152 > if x != nil {
153 > if x, ok := x.Attributes.(*ChasmNodeMetadata_ComponentAttributes); ok { chasm.pb.go
154 > return x.ComponentAttributes chasm.pb.go
155 > }
156 }
157 > return nil chasm.pb.go
158 }
159
160 > func (x *ChasmNodeMetadata) GetDataAttributes() *ChasmDataAttributes { chasm.pb.go
161 > if x != nil {
162 > if x, ok := x.Attributes.(*ChasmNodeMetadata_DataAttributes); ok { chasm.pb.go
163 > return x.DataAttributes chasm.pb.go
164 > }
165 }
166 return nil
167 }
168
169 > func (x *ChasmNodeMetadata) GetCollectionAttributes() *ChasmCollectionAttributes { chasm.pb.go
170 > if x != nil {
171 > if x, ok := x.Attributes.(*ChasmNodeMetadata_CollectionAttributes); ok {
172 return x.CollectionAttributes
173 }
174 }
175 > return nil chasm.pb.go
176 }
177
267 }
268
269 > func (x *ChasmComponentAttributes) GetTypeId() uint32 { chasm.pb.go
270 > if x != nil {
271 > return x.TypeId
272 > }
273 return 0
274 }
275
276 > func (x *ChasmComponentAttributes) GetSideEffectTasks() []*ChasmComponentAttributes_Task { chasm.pb.go
277 > if x != nil {
278 > return x.SideEffectTasks
279 > }
280 return nil
281 }
282
283 > func (x *ChasmComponentAttributes) GetPureTasks() []*ChasmComponentAttributes_Task { chasm.pb.go
284 > if x != nil {
285 > return x.PureTasks
286 > }
287 return nil
288 }
289
290 > func (x *ChasmComponentAttributes) GetDetached() bool { chasm.pb.go
291 > if x != nil {
292 > return x.Detached
293 > }
294 return false
295 }
1180 }
1181
1182 > func init() { file_temporal_server_api_persistence_v1_chasm_proto_init() } chasm.pb.go
1183 > func file_temporal_server_api_persistence_v1_chasm_proto_init() {
1184 > if File_temporal_server_api_persistence_v1_chasm_proto != nil {
1185 > return
1186 > }
1187 > file_temporal_server_api_persistence_v1_hsm_proto_init()
1188 > file_temporal_server_api_persistence_v1_chasm_proto_msgTypes[1].OneofWrappers = []any{
1189 > (*ChasmNodeMetadata_ComponentAttributes)(nil),
1190 > (*ChasmNodeMetadata_DataAttributes)(nil),
1191 > (*ChasmNodeMetadata_CollectionAttributes)(nil),
1192 > (*ChasmNodeMetadata_PointerAttributes)(nil),
1193 > }
1194 > file_temporal_server_api_persistence_v1_chasm_proto_msgTypes[10].OneofWrappers = []any{
1195 > (*ChasmNexusCompletion_Success)(nil),
1196 > (*ChasmNexusCompletion_Failure)(nil),
1197 > }
1198 > type x struct{}
1199 > out := protoimpl.TypeBuilder{
1200 > File: protoimpl.DescBuilder{
1201 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
1202 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_chasm_proto_rawDesc), len(file_temporal_server_api_persistence_v1_chasm_proto_rawDesc)),
1203 > NumEnums: 0,
1204 > NumMessages: 15,
1205 > NumExtensions: 0,
1206 > NumServices: 0,
1207 > },
1208 > GoTypes: file_temporal_server_api_persistence_v1_chasm_proto_goTypes,
1209 > DependencyIndexes: file_temporal_server_api_persistence_v1_chasm_proto_depIdxs,
1210 > MessageInfos: file_temporal_server_api_persistence_v1_chasm_proto_msgTypes,
1211 > }.Build()
1212 > File_temporal_server_api_persistence_v1_chasm_proto = out.File
1213 > file_temporal_server_api_persistence_v1_chasm_proto_goTypes = nil
1214 > file_temporal_server_api_persistence_v1_chasm_proto_depIdxs = nil
1215 }
go.temporal.io/server/chasm/registrable_task.go 75 covered LOC · 13 ranges

Open complete file

50 handler SideEffectTaskHandler[C, T],
51 opts ...RegistrableTaskOption,
52 > ) *RegistrableTask { registrable_task.go
53 > return newRegistrableTask(
54 > taskType,
55 > reflect.TypeFor[T](),
56 > reflect.TypeFor[C](),
57 > func(
58 > ctx Context,
59 > component any,
60 > taskInvocation TaskInvocation,
61 > taskData any,
62 > registry *Registry,
63 > ) (bool, error) {
64 > return handler.Validate( registrable_task.go
65 > ctx,
66 > component.(C),
67 > taskInvocation,
68 > taskData.(T),
69 > )
70 > },
71 nil, // pureTaskExecuteFn is not used for side effect tasks
72 func(
90 handler PureTaskHandler[C, T],
91 opts ...RegistrableTaskOption,
92 > ) *RegistrableTask { registrable_task.go
93 > return newRegistrableTask(
94 > taskType,
95 > reflect.TypeFor[T](),
96 > reflect.TypeFor[C](),
97 > func(
98 > ctx Context,
99 > component any,
100 > taskInvocation TaskInvocation,
101 > taskData any,
102 > registry *Registry,
103 > ) (bool, error) {
104 > return handler.Validate( registrable_task.go
105 > ctx,
106 > component.(C),
107 > taskInvocation,
108 > taskData.(T),
109 > )
110 > },
111 func(
112 ctx MutableContext,
115 taskData any,
116 registry *Registry,
117 > ) error { registrable_task.go
118 > return handler.Execute(
119 > ctx,
120 > component.(C),
121 > taskAttrs,
122 > taskData.(T),
123 > )
124 > },
125 nil, // sideEffectTaskExecuteFn is not used for pure tasks
126 true,
139 sideEffectTaskDiscardFn sideEffectTaskDiscardFn,
140 opts ...RegistrableTaskOption,
141 > ) *RegistrableTask { registrable_task.go
142 > rt := &RegistrableTask{
143 > taskType: taskType,
144 > goType: goType,
145 > componentGoType: componentGoType,
146 > validateFn: validateFn,
147 > pureTaskExecuteFn: pureTaskExecuteFn,
148 > sideEffectTaskExecuteFn: sideEffectTaskExecuteFn,
149 > sideEffectTaskDiscardFn: sideEffectTaskDiscardFn,
150 > isPureTask: isPureTask,
151 > }
152 >
153 > for _, opt := range opts {
154 opt(rt)
155 }
156
157 > return rt registrable_task.go
158 }
159
160 func (rt *RegistrableTask) registerToLibrary(
161 library namer,
162 > ) (string, uint32, error) { registrable_task.go
163 > if rt.library != nil {
164 return "", 0, fmt.Errorf("task %s is already registered in library %s", rt.taskType, rt.library.Name())
165 }
166
167 > rt.library = library registrable_task.go
168 >
169 > fqn := rt.fqType()
170 > rt.taskTypeID = GenerateTypeID(fqn)
171 > // If outboundTaskGroup wasn't set on creation default it here,
172 > // since this is the first place we will have the fqn.
173 > if rt.outboundTaskGroup == "" {
174 > rt.outboundTaskGroup = fqn registrable_task.go
175 > }
176 > return fqn, rt.taskTypeID, nil registrable_task.go
177 }
178
190 // the library name and the task type. This is used to uniquely identify
191 // the task in the registry.
192 > func (rt *RegistrableTask) fqType() string { registrable_task.go
193 > if rt.library == nil {
194 // this should never happen because the task is only accessible from the library.
195 panic("task is not registered to a library")
196 }
197 > return FullyQualifiedName(rt.library.Name(), rt.taskType) registrable_task.go
198 }
199
go.temporal.io/server/chasm/fields_iterator.go 71 covered LOC · 34 ranges

Open complete file

41 //
42 //nolint:revive // cognitive complexity 26 (> max enabled 25)
43 > func fieldsOf(valueV reflect.Value) iter.Seq[fieldInfo] { fields_iterator.go
44 > valueT := valueV.Type()
45 > dataFieldName := ""
46 > return func(yield func(fi fieldInfo) bool) {
47 > for i := 0; i < valueT.Elem().NumField(); i++ {
48 > fieldV := valueV.Elem().Field(i)
49 > fieldT := fieldV.Type()
50 > if fieldT == UnimplementedComponentT {
51 > continue fields_iterator.go
52 }
53
54 > fieldN := fieldName(valueT.Elem().Field(i)) fields_iterator.go
55 > var fieldErr error
56 > fieldK := fieldKindUnspecified
57 > if fieldT.AssignableTo(protoMessageT) {
58 > if dataFieldName != "" { fields_iterator.go
59 fieldErr = serviceerror.NewInternalf("%s.%s: only one data field %s (implements proto.Message) allowed in component", valueT, fieldN, dataFieldName)
60 }
61 > dataFieldName = fieldN fields_iterator.go
62 > fieldK = fieldKindData
63 > } else { fields_iterator.go
64 > prefix := genericTypePrefix(fieldT)
65 > if strings.HasPrefix(prefix, "*") {
66 switch prefix[1:] {
67 case chasmFieldTypePrefix,
73 continue
74 }
75 > } else { fields_iterator.go
76 > switch prefix {
77 > case chasmFieldTypePrefix: fields_iterator.go
78 > fieldK = fieldKindSubField
79 > case chasmMapTypePrefix: fields_iterator.go
80 > fieldK = fieldKindSubMap
81 case chasmMSPointerType:
82 fieldK = fieldKindMutableState
83 > case chasmParentPointerTypePrefix: fields_iterator.go
84 > fieldK = fieldKindParentPtr
85 > default: fields_iterator.go
86 > continue // Skip non-CHASM fields.
87 }
88 }
90 }
91
92 > if !yield(fieldInfo{val: fieldV, typ: fieldT, name: fieldN, kind: fieldK, err: fieldErr}) { fields_iterator.go
93 return
94 }
95 }
96 // If the data field is not found, generate one more fake field with only an error set.
97 > if dataFieldName == "" { fields_iterator.go
98 yield(fieldInfo{err: serviceerror.NewInternalf("%s: no data field (implements proto.Message) found", valueT)})
99 }
102
103 // unmanagedFieldsOf yields all non-CHASM managed fields of a struct.
104 > func unmanagedFieldsOf(valueT reflect.Type) iter.Seq[fieldInfo] { fields_iterator.go
105 > return func(yield func(fi fieldInfo) bool) {
106 > if valueT.Kind() == reflect.Pointer {
107 > valueT = valueT.Elem() fields_iterator.go
108 > }
109 > for field := range valueT.Fields() { fields_iterator.go
110 > fieldT := field.Type
111 > if fieldT == UnimplementedComponentT {
112 > continue fields_iterator.go
113 }
114
115 // Skip the data field, which is always CHASM-managed.
116 > if fieldT.AssignableTo(protoMessageT) { fields_iterator.go
117 > continue fields_iterator.go
118 }
119
120 > fieldN := fieldName(field) fields_iterator.go
121 > prefix := genericTypePrefix(fieldT)
122 > switch prefix {
123 case chasmFieldTypePrefix,
124 chasmMapTypePrefix,
125 chasmMSPointerType,
126 > chasmParentPointerTypePrefix: fields_iterator.go
127 > continue // Skip CHASM fields.
128 > default: fields_iterator.go
129 > if !yield(fieldInfo{typ: fieldT, name: fieldN}) {
130 return
131 }
135 }
136
137 > func genericTypePrefix(t reflect.Type) string { fields_iterator.go
138 > tn := t.String()
139 > if tn == chasmMSPointerType {
140 return chasmMSPointerType
141 }
142 > bracketPos := strings.Index(tn, "[") fields_iterator.go
143 > if bracketPos == -1 {
144 > return "" fields_iterator.go
145 > }
146 > return tn[:bracketPos+1] fields_iterator.go
147 }
148
149 > func fieldName(f reflect.StructField) string { fields_iterator.go
150 > if tagName := f.Tag.Get(fieldNameTag); tagName != "" {
151 return tagName
152 }
153 > return f.Name fields_iterator.go
154 }
155
161 // This is used at registration time to validate that archetypes using Visibility
162 // have configured a businessID alias.
163 > func hasVisibilityField(componentT reflect.Type) bool { fields_iterator.go
164 > if componentT.Kind() == reflect.Pointer {
165 > componentT = componentT.Elem() fields_iterator.go
166 > }
167 > if componentT.Kind() != reflect.Struct { fields_iterator.go
168 return false
169 }
170 > for field := range componentT.Fields() { fields_iterator.go
171 > fieldT := field.Type
172 > if fieldT == visibilityFieldT {
173 > return true fields_iterator.go
174 > }
175 }
176 > return false fields_iterator.go
177 }
go.temporal.io/server/chasm/lib/scheduler/library.go 70 covered LOC · 4 ranges

Open complete file

40 BackfillerTaskHandler *BackfillerTaskHandler,
41 MigrateToWorkflowTaskHandler *SchedulerMigrateToWorkflowTaskHandler,
42 > ) *Library { library.go
43 > return &Library{
44 > config: config,
45 > handler: handler,
46 > SchedulerIdleTaskHandler: SchedulerIdleTaskHandler,
47 > SchedulerCallbacksTaskHandler: SchedulerCallbacksTaskHandler,
48 > GeneratorTaskHandler: GeneratorTaskHandler,
49 > InvokerExecuteTaskHandler: InvokerExecuteTaskHandler,
50 > InvokerProcessBufferTaskHandler: InvokerProcessBufferTaskHandler,
51 > BackfillerTaskHandler: BackfillerTaskHandler,
52 > MigrateToWorkflowTaskHandler: MigrateToWorkflowTaskHandler,
53 > }
54 > }
55
56 > func (l *Library) Name() string { library.go
57 > return chasm.SchedulerLibraryName
58 > }
59
60 > func (l *Library) Components() []*chasm.RegistrableComponent { library.go
61 > return []*chasm.RegistrableComponent{
62 > chasm.NewRegistrableComponent[*Scheduler](
63 > chasm.SchedulerComponentName,
64 > chasm.WithBusinessIDAlias("ScheduleId"),
65 > chasm.WithSearchAttributes(
66 > executionStatusSearchAttribute,
67 > scheduleNextActionTimeSearchAttribute,
68 > scheduleIdleCloseTimeSearchAttribute,
69 > scheduleRunningWorkflowCountSearchAttribute,
70 > scheduleBufferedStartsCountSearchAttribute,
71 > ),
72 > // Exposes Tweakables to scheduler components via the CHASM context
73 > // (see tweakablesFromContext).
74 > chasm.WithContextValues(l.config.contextValues()),
75 > ),
76 > chasm.NewRegistrableComponent[*Generator]("generator"),
77 > chasm.NewRegistrableComponent[*Invoker]("invoker"),
78 > chasm.NewRegistrableComponent[*Backfiller]("backfiller"),
79 > chasm.NewRegistrableComponent[*EventLog]("eventlog"),
80 > }
81 > }
82
83 > func (l *Library) Tasks() []*chasm.RegistrableTask { library.go
84 > return []*chasm.RegistrableTask{
85 > chasm.NewRegistrablePureTask(
86 > "idle",
87 > l.SchedulerIdleTaskHandler,
88 > ),
89 > chasm.NewRegistrableSideEffectTask(
90 > "callbacks",
91 > l.SchedulerCallbacksTaskHandler,
92 > ),
93 > chasm.NewRegistrablePureTask(
94 > "generate",
95 > l.GeneratorTaskHandler,
96 > ),
97 > chasm.NewRegistrableSideEffectTask(
98 > "execute",
99 > l.InvokerExecuteTaskHandler,
100 > ),
101 > chasm.NewRegistrablePureTask(
102 > "processBuffer",
103 > l.InvokerProcessBufferTaskHandler,
104 > ),
105 > chasm.NewRegistrablePureTask(
106 > "backfill",
107 > l.BackfillerTaskHandler,
108 > ),
109 > chasm.NewRegistrableSideEffectTask(
110 > "migrateToWorkflow",
111 > l.MigrateToWorkflowTaskHandler,
112 > ),
113 > }
114 > }
115
116 func (l *Library) RegisterServices(server *grpc.Server) {
go.temporal.io/server/chasm/registrable_component.go 69 covered LOC · 27 ranges

Open complete file

65 // If a registrable component is not detached by default, a component definition
66 // can specify its child as detached via ComponentFieldDetached() option.
67 > func WithDetached() RegistrableComponentOption { registrable_component.go
68 > return func(rc *RegistrableComponent) {
69 > rc.detached = true
70 > }
71 }
72
73 // IsDetached returns true if the component type is registered as detached.
74 > func (rc *RegistrableComponent) IsDetached() bool { registrable_component.go
75 > return rc.detached
76 > }
77
78 // WithBusinessIDAlias allows specifying the business ID alias of the component.
80 func WithBusinessIDAlias(
81 alias string,
82 > ) RegistrableComponentOption { registrable_component.go
83 > return func(rc *RegistrableComponent) {
84 > if rc.searchAttributesMapper == nil {
85 > rc.searchAttributesMapper = newVisibilitySearchAttributesMapper() registrable_component.go
86 > }
87 > if _, ok := rc.searchAttributesMapper.aliasToField[alias]; ok { registrable_component.go
88 //nolint:forbidigo
89 panic(fmt.Sprintf("registrable component validation error: business ID alias %q is already defined as a search attribute", alias))
90 }
91 > if _, ok := rc.searchAttributesMapper.systemAliasToField[alias]; ok { registrable_component.go
92 //nolint:forbidigo
93 panic(fmt.Sprintf("registrable component validation error: business ID alias %q is already defined as a system search attribute", alias))
94 }
95 > rc.searchAttributesMapper.systemAliasToField[alias] = sadefs.WorkflowID registrable_component.go
96 > rc.searchAttributesMapper.fieldToAlias[sadefs.WorkflowID] = alias
97 > rc.searchAttributesMapper.saTypeMap[sadefs.WorkflowID] = enumspb.INDEXED_VALUE_TYPE_KEYWORD
98 }
99 }
101 func WithSearchAttributes(
102 searchAttributes ...SearchAttribute,
103 > ) RegistrableComponentOption { registrable_component.go
104 > return func(rc *RegistrableComponent) {
105 > if len(searchAttributes) == 0 {
106 return
107 }
108
109 > if rc.searchAttributesMapper == nil { registrable_component.go
110 rc.searchAttributesMapper = newVisibilitySearchAttributesMapper()
111 }
112
113 > for _, sa := range searchAttributes { registrable_component.go
114 > alias := sa.definition().alias
115 > field := sa.definition().field
116 > valueType := sa.definition().valueType
117 >
118 > // An identity-mapped system search attribute (alias == field, e.g. TaskQueue,
119 > // ExecutionTime) overrides that system column directly, so it is recorded only in
120 > // overriddenSystemFields; queries resolve via the system column.
121 > if field == alias && sadefs.IsSystem(field) {
122 if !sadefs.IsChasmOverridableSystem(field) {
123 //nolint:forbidigo
132 }
133
134 > if sadefs.IsChasmSystem(alias) { registrable_component.go
135 //nolint:forbidigo
136 panic(fmt.Sprintf("registrable component validation error: CHASM search attribute alias %q is a CHASM system search attribute", alias))
137 }
138 > if !sadefs.IsSystem(alias) && sadefs.IsReserved(alias) { registrable_component.go
139 //nolint:forbidigo
140 panic(fmt.Sprintf("registrable component validation error: CHASM search attribute alias %q is a reserved search attribute", alias))
141 }
142
143 > if _, ok := rc.searchAttributesMapper.systemAliasToField[alias]; ok { registrable_component.go
144 //nolint:forbidigo
145 panic(fmt.Sprintf("registrable component validation error: CHASM search attribute alias %q is already defined as a system search attribute alias", alias))
146 }
147 > if _, ok := rc.searchAttributesMapper.aliasToField[alias]; ok { registrable_component.go
148 //nolint:forbidigo
149 panic(fmt.Sprintf("registrable component validation error: search attribute alias %q is already defined", alias))
150 }
151 > if _, ok := rc.searchAttributesMapper.fieldToAlias[field]; ok { registrable_component.go
152 //nolint:forbidigo
153 panic(fmt.Sprintf("registrable component validation error: search attribute field %q is already defined", field))
154 }
155
156 > rc.searchAttributesMapper.aliasToField[alias] = field registrable_component.go
157 > rc.searchAttributesMapper.fieldToAlias[field] = alias
158 > rc.searchAttributesMapper.saTypeMap[field] = valueType
159 }
160 }
173 func WithContextValues(
174 keyVals map[any]any,
175 > ) RegistrableComponentOption { registrable_component.go
176 > return func(rc *RegistrableComponent) {
177 > if rc.contextValues == nil {
178 > rc.contextValues = make(map[any]any, len(keyVals))
179 > }
180 > maps.Copy(rc.contextValues, keyVals)
181 }
182 }
184 func (rc *RegistrableComponent) registerToLibrary(
185 library namer,
186 > ) (string, uint32, error) { registrable_component.go
187 > if rc.library != nil {
188 return "", 0, fmt.Errorf("component %s is already registered in library %s", rc.componentType, rc.library.Name())
189 }
190
191 > rc.library = library registrable_component.go
192 > rc.fqn = FullyQualifiedName(rc.library.Name(), rc.componentType)
193 > rc.componentID = GenerateTypeID(rc.fqn)
194 > return rc.fqn, rc.componentID, nil
195 }
196
203 // The generated ID is used to uniquely identify components and tasks within the CHASM framework. The same FQN will
204 // always produce the same ID.
205 > func GenerateTypeID(fqn string) uint32 { registrable_component.go
206 > return farm.Fingerprint32([]byte(fqn))
207 > }
208
209 // hasBusinessIDAlias returns true if the component has a businessID alias configured
210 // via WithBusinessIDAlias option.
211 > func (rc *RegistrableComponent) hasBusinessIDAlias() bool { registrable_component.go
212 > if rc.searchAttributesMapper == nil {
213 return false
214 }
215 > _, ok := rc.searchAttributesMapper.fieldToAlias[sadefs.WorkflowID] registrable_component.go
216 > return ok
217 }
218
225 // the library name and the component type. This is used to uniquely identify
226 // the component in the registry.
227 > func (rc *RegistrableComponent) fqType() string { registrable_component.go
228 > if rc.fqn == "" {
229 // this should never happen because the component is only accessible from the library.
230 panic("component is not registered to a library")
231 }
232 > return rc.fqn registrable_component.go
233 }
go.temporal.io/server/api/persistence/v1/executions.pb.go 60 covered LOC · 1 range

Open complete file

5706 }
5707
5708 > func init() { file_temporal_server_api_persistence_v1_executions_proto_init() } executions.pb.go
5709 > func file_temporal_server_api_persistence_v1_executions_proto_init() {
5710 > if File_temporal_server_api_persistence_v1_executions_proto != nil {
5711 > return
5712 > }
5713 > file_temporal_server_api_persistence_v1_chasm_proto_init()
5714 > file_temporal_server_api_persistence_v1_hsm_proto_init()
5715 > file_temporal_server_api_persistence_v1_queues_proto_init()
5716 > file_temporal_server_api_persistence_v1_update_proto_init()
5717 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[1].OneofWrappers = []any{
5718 > (*WorkflowExecutionInfo_LastWorkflowTaskFailureCause)(nil),
5719 > (*WorkflowExecutionInfo_LastWorkflowTaskTimedOutType)(nil),
5720 > }
5721 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[8].OneofWrappers = []any{
5722 > (*TransferTaskInfo_CloseExecutionTaskDetails_)(nil),
5723 > (*TransferTaskInfo_ChasmTaskInfo)(nil),
5724 > }
5725 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[10].OneofWrappers = []any{
5726 > (*VisibilityTaskInfo_ChasmTaskInfo)(nil),
5727 > }
5728 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[11].OneofWrappers = []any{
5729 > (*TimerTaskInfo_ChasmTaskInfo)(nil),
5730 > }
5731 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[13].OneofWrappers = []any{
5732 > (*OutboundTaskInfo_StateMachineInfo)(nil),
5733 > (*OutboundTaskInfo_ChasmTaskInfo)(nil),
5734 > (*OutboundTaskInfo_WorkerCommandsTask)(nil),
5735 > }
5736 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[17].OneofWrappers = []any{
5737 > (*ActivityInfo_UseWorkflowBuildIdInfo_)(nil),
5738 > (*ActivityInfo_LastIndependentlyAssignedBuildId)(nil),
5739 > }
5740 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[23].OneofWrappers = []any{
5741 > (*Callback_Nexus_)(nil),
5742 > (*Callback_Hsm)(nil),
5743 > }
5744 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[40].OneofWrappers = []any{
5745 > (*ActivityInfo_PauseInfo_Manual_)(nil),
5746 > (*ActivityInfo_PauseInfo_RuleId)(nil),
5747 > }
5748 > file_temporal_server_api_persistence_v1_executions_proto_msgTypes[46].OneofWrappers = []any{
5749 > (*CallbackInfo_Trigger_WorkflowClosed)(nil),
5750 > }
5751 > type x struct{}
5752 > out := protoimpl.TypeBuilder{
5753 > File: protoimpl.DescBuilder{
5754 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
5755 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_executions_proto_rawDesc), len(file_temporal_server_api_persistence_v1_executions_proto_rawDesc)),
5756 > NumEnums: 0,
5757 > NumMessages: 47,
5758 > NumExtensions: 0,
5759 > NumServices: 0,
5760 > },
5761 > GoTypes: file_temporal_server_api_persistence_v1_executions_proto_goTypes,
5762 > DependencyIndexes: file_temporal_server_api_persistence_v1_executions_proto_depIdxs,
5763 > MessageInfos: file_temporal_server_api_persistence_v1_executions_proto_msgTypes,
5764 > }.Build()
5765 > File_temporal_server_api_persistence_v1_executions_proto = out.File
5766 > file_temporal_server_api_persistence_v1_executions_proto_goTypes = nil
5767 > file_temporal_server_api_persistence_v1_executions_proto_depIdxs = nil
5768 }
go.temporal.io/server/common/testing/testvars/test_vars.go 58 covered LOC · 11 ranges

Open complete file

37 )
38
39 > func New(testNamer testNamer) *TestVars { test_vars.go
40 > return newFromName(testNamer.Name())
41 > }
42
43 > func newFromName(testName string) *TestVars { test_vars.go
44 > th := hash(testName)
45 > return &TestVars{
46 > testName: testName,
47 > testHash: th,
48 > an: newAny(testName, th),
49 > }
50 > }
51
52 > func getOrCreate[T any](tv *TestVars, key string, initialValGen func(key string) T, valNSetter func(val T, n int) T) T { test_vars.go
53 > v, _ := tv.values.LoadOrStore(key, initialValGen(key))
54 >
55 > n, ok := tv.numbers.Load(key)
56 > if !ok {
57 > //revive:disable-next-line:unchecked-type-assertion test_vars.go
58 > return v.(T)
59 > }
60
61 //revive:disable-next-line:unchecked-type-assertion
85 }
86
87 > func (tv *TestVars) uniqueString(key string) string { test_vars.go
88 > return fmt.Sprintf("%s_%s", tv.testName, key)
89 > }
90
91 > func (tv *TestVars) uuidString(_ string) string { test_vars.go
92 > return uuid.NewString()
93 > }
94
95 func (tv *TestVars) emptyString(_ string) string {
138 */
139
140 > func (tv *TestVars) NamespaceID() namespace.ID { test_vars.go
141 > return getOrCreate(tv, "namespace_id",
142 > func(key string) namespace.ID {
143 > return namespace.ID(tv.uuidString(key))
144 > },
145 func(val namespace.ID, n int) namespace.ID {
146 return namespace.ID(tv.uuidNSetter(val.String(), n))
153 }
154
155 > func (tv *TestVars) NamespaceName() namespace.Name { test_vars.go
156 > return getOrCreate(tv, "namespace_name",
157 > func(key string) namespace.Name {
158 > return namespace.Name(tv.uniqueString(key))
159 > },
160 func(val namespace.Name, n int) namespace.Name {
161 return namespace.Name(tv.stringNSetter(val.String(), n))
168 }
169
170 > func (tv *TestVars) Namespace() *namespace.Namespace { test_vars.go
171 > return namespace.NewLocalNamespaceForTest(
172 > &persistencespb.NamespaceInfo{
173 > Id: tv.NamespaceID().String(),
174 > Name: tv.NamespaceName().String(),
175 > },
176 > &persistencespb.NamespaceConfig{
177 > Retention: timestamp.DurationFromDays(int32(tv.Any().Int())),
178 > BadBinaries: &namespacepb.BadBinaries{
179 > Binaries: map[string]*namespacepb.BadBinaryInfo{
180 > tv.Any().String(): nil,
181 > },
182 > },
183 > },
184 > tv.Global().ClusterName(),
185 > )
186 > }
187
188 func (tv *TestVars) WorkflowID() string {
440
441 // ----------- Generic methods ------------
442 > func (tv *TestVars) Any() Any { test_vars.go
443 > return tv.an
444 > }
445
446 > func (tv *TestVars) Global() Global { test_vars.go
447 > return newGlobal()
448 > }
449
450 func (tv *TestVars) WorkerDeploymentOptions(versioned bool) *deploymentpb.WorkerDeploymentOptions {
go.temporal.io/server/api/persistence/v1/hsm.pb.go 49 covered LOC · 8 ranges

Open complete file

478 func (*VersionedTransition) ProtoMessage() {}
479
480 > func (x *VersionedTransition) ProtoReflect() protoreflect.Message { hsm.pb.go
481 > mi := &file_temporal_server_api_persistence_v1_hsm_proto_msgTypes[6]
482 > if x != nil {
483 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) hsm.pb.go
484 > if ms.LoadMessageInfo() == nil {
485 > ms.StoreMessageInfo(mi)
486 > }
487 > return ms
488 }
489 > return mi.MessageOf(x) hsm.pb.go
490 }
491
495 }
496
497 > func (x *VersionedTransition) GetNamespaceFailoverVersion() int64 { hsm.pb.go
498 > if x != nil {
499 > return x.NamespaceFailoverVersion hsm.pb.go
500 > }
501 return 0
502 }
503
504 > func (x *VersionedTransition) GetTransitionCount() int64 { hsm.pb.go
505 > if x != nil {
506 > return x.TransitionCount hsm.pb.go
507 > }
508 return 0
509 }
895 }
896
897 > func init() { file_temporal_server_api_persistence_v1_hsm_proto_init() } hsm.pb.go
898 > func file_temporal_server_api_persistence_v1_hsm_proto_init() {
899 > if File_temporal_server_api_persistence_v1_hsm_proto != nil {
900 > return
901 > }
902 > file_temporal_server_api_persistence_v1_hsm_proto_msgTypes[8].OneofWrappers = []any{
903 > (*StateMachineTombstone_ActivityScheduledEventId)(nil),
904 > (*StateMachineTombstone_TimerId)(nil),
905 > (*StateMachineTombstone_ChildExecutionInitiatedEventId)(nil),
906 > (*StateMachineTombstone_RequestCancelInitiatedEventId)(nil),
907 > (*StateMachineTombstone_SignalExternalInitiatedEventId)(nil),
908 > (*StateMachineTombstone_UpdateId)(nil),
909 > (*StateMachineTombstone_StateMachinePath)(nil),
910 > (*StateMachineTombstone_ChasmNodePath)(nil),
911 > }
912 > type x struct{}
913 > out := protoimpl.TypeBuilder{
914 > File: protoimpl.DescBuilder{
915 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
916 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_hsm_proto_rawDesc), len(file_temporal_server_api_persistence_v1_hsm_proto_rawDesc)),
917 > NumEnums: 0,
918 > NumMessages: 12,
919 > NumExtensions: 0,
920 > NumServices: 0,
921 > },
922 > GoTypes: file_temporal_server_api_persistence_v1_hsm_proto_goTypes,
923 > DependencyIndexes: file_temporal_server_api_persistence_v1_hsm_proto_depIdxs,
924 > MessageInfos: file_temporal_server_api_persistence_v1_hsm_proto_msgTypes,
925 > }.Build()
926 > File_temporal_server_api_persistence_v1_hsm_proto = out.File
927 > file_temporal_server_api_persistence_v1_hsm_proto_goTypes = nil
928 > file_temporal_server_api_persistence_v1_hsm_proto_depIdxs = nil
929 }
go.temporal.io/server/chasm/node_backend_mock.go 49 covered LOC · 15 ranges

Open complete file

51 }
52
53 > func (m *MockNodeBackend) GetExecutionState() *persistencespb.WorkflowExecutionState { node_backend_mock.go
54 > if m.HandleGetExecutionState != nil {
55 return m.HandleGetExecutionState()
56 }
57 > return &persistencespb.WorkflowExecutionState{} node_backend_mock.go
58 }
59
72 }
73
74 > func (m *MockNodeBackend) GetCurrentVersion() int64 { node_backend_mock.go
75 > if m.HandleGetCurrentVersion != nil {
76 > return m.HandleGetCurrentVersion() node_backend_mock.go
77 > }
78 return 0
79 }
80
81 > func (m *MockNodeBackend) NextTransitionCount() int64 { node_backend_mock.go
82 > if m.HandleNextTransitionCount != nil {
83 > return m.HandleNextTransitionCount() node_backend_mock.go
84 > }
85 return 0
86 }
93 }
94
95 > func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey { node_backend_mock.go
96 > if m.HandleGetWorkflowKey != nil {
97 > return m.HandleGetWorkflowKey() node_backend_mock.go
98 > }
99 return definition.WorkflowKey{}
100 }
101
102 > func (m *MockNodeBackend) AddTasks(ts ...tasks.Task) { node_backend_mock.go
103 > m.mu.Lock()
104 > defer m.mu.Unlock()
105 > if m.TasksByCategory == nil {
106 > m.TasksByCategory = make(map[tasks.Category][]tasks.Task, 1)
107 > }
108 > for _, task := range ts {
109 > category := task.GetCategory()
110 > m.TasksByCategory[category] = append(m.TasksByCategory[category], task)
111 > }
112 }
113
114 > func (m *MockNodeBackend) DeleteCHASMPureTasks(maxScheduledTime time.Time) { node_backend_mock.go
115 > m.mu.Lock()
116 > defer m.mu.Unlock()
117 >
118 > m.DeletePureTaskCalls = append(m.DeletePureTaskCalls, maxScheduledTime)
119 > }
120
121 func (m *MockNodeBackend) LastDeletePureTaskCall() time.Time {
132 state enumsspb.WorkflowExecutionState,
133 status enumspb.WorkflowExecutionStatus,
134 > ) (bool, error) { node_backend_mock.go
135 > if m.HandleUpdateWorkflowStateStatus != nil {
136 ok, err := m.HandleUpdateWorkflowStateStatus(state, status)
137
146 }
147
148 > m.mu.Lock() node_backend_mock.go
149 > m.UpdateCalls = append(m.UpdateCalls, struct {
150 > State enumsspb.WorkflowExecutionState
151 > Status enumspb.WorkflowExecutionStatus
152 > }{State: state, Status: status})
153 > m.mu.Unlock()
154 >
155 > return false, nil
156 }
157
174 }
175
176 > func (m *MockNodeBackend) IsWorkflow() bool { node_backend_mock.go
177 > if m.HandleIsWorkflow != nil {
178 > return m.HandleIsWorkflow() node_backend_mock.go
179 > }
180 return false
181 }
219 }
220
221 > func (m *MockNodeBackend) GetNamespaceEntry() *namespace.Namespace { node_backend_mock.go
222 > if m.HandleGetNamespaceEntry != nil {
223 > return m.HandleGetNamespaceEntry()
224 > }
225 return nil
226 }
go.temporal.io/server/chasm/lib/scheduler/generator.go 48 covered LOC · 13 ranges

Open complete file

27 // NewGenerator returns an initialized Generator component, which should
28 // be parented under a Scheduler root node.
29 > func NewGenerator(ctx chasm.MutableContext) *Generator { generator.go
30 > generator := newGeneratorWithState(ctx, &schedulerpb.GeneratorState{
31 > LastProcessedTime: nil,
32 > })
33 > // Kick off initial generator run as an immediate task.
34 > generator.Generate(ctx)
35 > return generator
36 > }
37
38 > func newGeneratorWithState(ctx chasm.MutableContext, state *schedulerpb.GeneratorState) *Generator { generator.go
39 > generator := &Generator{
40 > GeneratorState: state,
41 > EventLog: chasm.NewComponentField(ctx, NewEventLog(ctx)),
42 > }
43 > return generator
44 > }
45
46 // Generate immediately kicks off a new GeneratorTask. Used after updating the
47 // schedule specification.
48 > func (g *Generator) Generate(ctx chasm.MutableContext) { generator.go
49 > g.scheduleTask(ctx, chasm.TaskScheduledTimeImmediate)
50 > }
51
52 // scheduleTask schedules a GeneratorTask at the given time.
53 > func (g *Generator) scheduleTask(ctx chasm.MutableContext, scheduledTime time.Time) { generator.go
54 > g.getOrCreateEventLog(ctx).LogEvent(ctx,
55 > fmt.Sprintf("scheduled generatorTask for %s", scheduledTime.Format(time.RFC3339)))
56 > ctx.AddTask(g, chasm.TaskAttributes{
57 > ScheduledTime: scheduledTime,
58 > }, &schedulerpb.GeneratorTask{})
59 > }
60
61 > func (g *Generator) LifecycleState(ctx chasm.Context) chasm.LifecycleState { generator.go
62 > return chasm.LifecycleStateRunning
63 > }
64
65 // UpdateFutureActionTimes computes and stores the next scheduled action times.
68 ctx chasm.MutableContext,
69 specBuilder *scheduler.SpecBuilder,
70 > ) { generator.go
71 > futureTimes, err := g.computeFutureActionTimes(ctx, specBuilder)
72 > if err != nil {
73 g.getOrCreateEventLog(ctx).LogEvent(ctx,
74 fmt.Sprintf("failed to update future action times: %v", err.Error()))
76 return
77 }
78 > g.FutureActionTimes = futureTimes generator.go
79 }
80
84 ctx chasm.Context,
85 specBuilder *scheduler.SpecBuilder,
86 > ) ([]*timestamppb.Timestamp, error) { generator.go
87 > sched := g.Scheduler.Get(ctx)
88 > spec, err := sched.getCompiledSpec(specBuilder)
89 > if err != nil {
90 return nil, err
91 }
92
93 > count := recentActionCount generator.go
94 > if sched.Schedule.State.LimitedActions {
95 count = min(int(sched.Schedule.State.RemainingActions), recentActionCount)
96 }
97
98 > futureTimes := make([]*timestamppb.Timestamp, 0, count) generator.go
99 > // Start from max(now, updateTime) to ensure we skip times before the last update.
100 > t := ctx.Now(g)
101 > if updateTime := sched.Info.GetUpdateTime().AsTime(); updateTime.After(t) {
102 t = updateTime
103 }
104 > for len(futureTimes) < count { generator.go
105 > res, err := spec.GetNextTime(sched.jitterSeed(), t)
106 > if err != nil || res.Next.IsZero() {
107 // Over-excluded spec (limit) or end of schedule: return a partial list.
108 break
109 }
110 > t = res.Next generator.go
111 > futureTimes = append(futureTimes, timestamppb.New(t))
112 }
113
114 > return futureTimes, nil generator.go
115 }
go.temporal.io/server/api/historyservice/v1/request_response.pb.go 45 covered LOC · 1 range

Open complete file

11956 }
11957
11958 > func init() { file_temporal_server_api_historyservice_v1_request_response_proto_init() } request_response.pb.go
11959 > func file_temporal_server_api_historyservice_v1_request_response_proto_init() {
11960 > if File_temporal_server_api_historyservice_v1_request_response_proto != nil {
11961 > return
11962 > }
11963 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[107].OneofWrappers = []any{
11964 > (*StreamWorkflowReplicationMessagesRequest_SyncReplicationState)(nil),
11965 > }
11966 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[108].OneofWrappers = []any{
11967 > (*StreamWorkflowReplicationMessagesResponse_Messages)(nil),
11968 > }
11969 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[134].OneofWrappers = []any{
11970 > (*CompleteNexusOperationChasmRequest_Success)(nil),
11971 > (*CompleteNexusOperationChasmRequest_Failure)(nil),
11972 > }
11973 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[136].OneofWrappers = []any{
11974 > (*CompleteNexusOperationRequest_Success)(nil),
11975 > (*CompleteNexusOperationRequest_Failure)(nil),
11976 > }
11977 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[162].OneofWrappers = []any{
11978 > (*ExecuteMultiOperationRequest_Operation_StartWorkflow)(nil),
11979 > (*ExecuteMultiOperationRequest_Operation_UpdateWorkflow)(nil),
11980 > }
11981 > file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[163].OneofWrappers = []any{
11982 > (*ExecuteMultiOperationResponse_Response_StartWorkflow)(nil),
11983 > (*ExecuteMultiOperationResponse_Response_UpdateWorkflow)(nil),
11984 > }
11985 > type x struct{}
11986 > out := protoimpl.TypeBuilder{
11987 > File: protoimpl.DescBuilder{
11988 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
11989 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_historyservice_v1_request_response_proto_rawDesc), len(file_temporal_server_api_historyservice_v1_request_response_proto_rawDesc)),
11990 > NumEnums: 0,
11991 > NumMessages: 171,
11992 > NumExtensions: 1,
11993 > NumServices: 0,
11994 > },
11995 > GoTypes: file_temporal_server_api_historyservice_v1_request_response_proto_goTypes,
11996 > DependencyIndexes: file_temporal_server_api_historyservice_v1_request_response_proto_depIdxs,
11997 > MessageInfos: file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes,
11998 > ExtensionInfos: file_temporal_server_api_historyservice_v1_request_response_proto_extTypes,
11999 > }.Build()
12000 > File_temporal_server_api_historyservice_v1_request_response_proto = out.File
12001 > file_temporal_server_api_historyservice_v1_request_response_proto_goTypes = nil
12002 > file_temporal_server_api_historyservice_v1_request_response_proto_depIdxs = nil
12003 }
go.temporal.io/server/common/metrics/defs.go 44 covered LOC · 8 ranges

Open complete file

20 )
21
22 > func NewTimerDef(name string, opts ...Option) timerDefinition { defs.go
23 > // This line cannot be combined with others!
24 > // This ensures the stack trace has information of the caller.
25 > def := newMetricDefinition(name, opts...)
26 > globalRegistry.register(def)
27 > return timerDefinition{def}
28 > }
29
30 > func NewBytesHistogramDef(name string, opts ...Option) histogramDefinition { defs.go
31 > // This line cannot be combined with others!
32 > // This ensures the stack trace has information of the caller.
33 > def := newMetricDefinition(name, append(opts, WithUnit(Bytes))...)
34 > globalRegistry.register(def)
35 > return histogramDefinition{def}
36 > }
37
38 > func NewDimensionlessHistogramDef(name string, opts ...Option) histogramDefinition { defs.go
39 > // This line cannot be combined with others!
40 > // This ensures the stack trace has information of the caller.
41 > def := newMetricDefinition(name, append(opts, WithUnit(Dimensionless))...)
42 > globalRegistry.register(def)
43 > return histogramDefinition{def}
44 > }
45
46 > func NewCounterDef(name string, opts ...Option) counterDefinition { defs.go
47 > // This line cannot be combined with others!
48 > // This ensures the stack trace has information of the caller.
49 > def := newMetricDefinition(name, opts...)
50 > globalRegistry.register(def)
51 > return counterDefinition{def}
52 > }
53
54 > func NewGaugeDef(name string, opts ...Option) gaugeDefinition { defs.go
55 > // This line cannot be combined with others!
56 > // This ensures the stack trace has information of the caller.
57 > def := newMetricDefinition(name, opts...)
58 > globalRegistry.register(def)
59 > return gaugeDefinition{def}
60 > }
61
62 func (d histogramDefinition) With(handler Handler) HistogramIface {
64 }
65
66 > func (d counterDefinition) With(handler Handler) CounterIface { defs.go
67 > return handler.Counter(d.name)
68 > }
69
70 > func (d gaugeDefinition) With(handler Handler) GaugeIface { defs.go
71 > return handler.Gauge(d.name)
72 > }
73
74 > func (d timerDefinition) With(handler Handler) TimerIface { defs.go
75 > return handler.Timer(d.name)
76 > }
go.temporal.io/server/api/matchingservice/v1/request_response.pb.go 43 covered LOC · 1 range

Open complete file

6833 }
6834
6835 > func init() { file_temporal_server_api_matchingservice_v1_request_response_proto_init() } request_response.pb.go
6836 > func file_temporal_server_api_matchingservice_v1_request_response_proto_init() {
6837 > if File_temporal_server_api_matchingservice_v1_request_response_proto != nil {
6838 > return
6839 > }
6840 > file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes[27].OneofWrappers = []any{
6841 > (*UpdateWorkerBuildIdCompatibilityRequest_ApplyPublicRequest_)(nil),
6842 > (*UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds_)(nil),
6843 > (*UpdateWorkerBuildIdCompatibilityRequest_PersistUnknownBuildId)(nil),
6844 > }
6845 > file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes[29].OneofWrappers = []any{
6846 > (*GetWorkerVersioningRulesRequest_Request)(nil),
6847 > }
6848 > file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes[31].OneofWrappers = []any{
6849 > (*UpdateWorkerVersioningRulesRequest_Request)(nil),
6850 > }
6851 > file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes[37].OneofWrappers = []any{
6852 > (*SyncDeploymentUserDataRequest_UpdateVersionData)(nil),
6853 > (*SyncDeploymentUserDataRequest_ForgetVersion)(nil),
6854 > }
6855 > file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes[56].OneofWrappers = []any{
6856 > (*DispatchNexusTaskResponse_HandlerError)(nil),
6857 > (*DispatchNexusTaskResponse_Response)(nil),
6858 > (*DispatchNexusTaskResponse_RequestTimeout)(nil),
6859 > (*DispatchNexusTaskResponse_Failure)(nil),
6860 > }
6861 > type x struct{}
6862 > out := protoimpl.TypeBuilder{
6863 > File: protoimpl.DescBuilder{
6864 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
6865 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_matchingservice_v1_request_response_proto_rawDesc), len(file_temporal_server_api_matchingservice_v1_request_response_proto_rawDesc)),
6866 > NumEnums: 0,
6867 > NumMessages: 97,
6868 > NumExtensions: 0,
6869 > NumServices: 0,
6870 > },
6871 > GoTypes: file_temporal_server_api_matchingservice_v1_request_response_proto_goTypes,
6872 > DependencyIndexes: file_temporal_server_api_matchingservice_v1_request_response_proto_depIdxs,
6873 > MessageInfos: file_temporal_server_api_matchingservice_v1_request_response_proto_msgTypes,
6874 > }.Build()
6875 > File_temporal_server_api_matchingservice_v1_request_response_proto = out.File
6876 > file_temporal_server_api_matchingservice_v1_request_response_proto_goTypes = nil
6877 > file_temporal_server_api_matchingservice_v1_request_response_proto_depIdxs = nil
6878 }
go.temporal.io/server/common/searchattribute/sadefs/constants.go 43 covered LOC · 15 ranges

Open complete file

261 }
262
263 > dbCustomSearchAttributeFieldNameRE = func() map[enumspb.IndexedValueType]*regexp.Regexp { constants.go
264 > res := map[enumspb.IndexedValueType]*regexp.Regexp{}
265 > for t := range defaultNumDBCustomSearchAttributes {
266 > res[t] = regexp.MustCompile(fmt.Sprintf(`^%s(0[1-9]|[1-9][0-9])$`, t.String()))
267 > }
268 > return res
269 }()
270 )
271
272 // System returns a clone of the system search attributes map.
273 > func System() map[string]enumspb.IndexedValueType { constants.go
274 > return maps.Clone(system)
275 > }
276
277 // Predefined returns a clone of the predefined search attributes map.
278 > func Predefined() map[string]enumspb.IndexedValueType { constants.go
279 > return maps.Clone(predefined)
280 > }
281
282 // PredefinedWhiteList returns a clone of the predefined whitelist search attributes map.
283 > func PredefinedWhiteList() map[string]enumspb.IndexedValueType { constants.go
284 > return maps.Clone(predefinedWhiteList)
285 > }
286
287 // Reserved returns a clone of the reserved field names map.
291
292 // IsSystem returns true if name is system search attribute
293 > func IsSystem(name string) bool { constants.go
294 > _, ok := system[name]
295 > return ok
296 > }
297
298 // IsReserved returns true if name is system reserved and can't be used as custom search attribute name.
299 > func IsReserved(name string) bool { constants.go
300 > if _, ok := system[name]; ok {
301 return true
302 }
303 > if _, ok := predefined[name]; ok { constants.go
304 return true
305 }
306 > if _, ok := reserved[name]; ok { constants.go
307 return true
308 }
309 > return strings.HasPrefix(name, ReservedPrefix) constants.go
310 }
311
323
324 // IsChasmSystem returns true if name is a system search attribute used by CHASM
325 > func IsChasmSystem(name string) bool { constants.go
326 > _, ok := chasmSystemSearchAttributes[name]
327 > return ok
328 > }
329
330 // IsChasmOverridableSystem returns true if name is a system search attribute whose dedicated
343 // GetSqlDbColName maps system and reserved search attributes to column names for SQL tables.
344 // If the input is not a system or reserved search attribute, then it returns the input.
345 > func GetSqlDbColName(name string) string { constants.go
346 > if fieldName, ok := sqlDbSystemNameToColName[name]; ok {
347 > return fieldName constants.go
348 > }
349 return name
350 }
352 func GetDBIndexSearchAttributes(
353 override map[enumspb.IndexedValueType]int,
354 > ) *persistencespb.IndexSearchAttributes { constants.go
355 > csa := map[string]enumspb.IndexedValueType{}
356 > for saType, defaultNumAttrs := range defaultNumDBCustomSearchAttributes {
357 > numAttrs := defaultNumAttrs
358 > if value, ok := override[saType]; ok {
359 numAttrs = value
360 }
361 > for i := range numAttrs { constants.go
362 > csa[fmt.Sprintf("%s%02d", saType.String(), i+1)] = saType
363 > }
364 }
365 > return &persistencespb.IndexSearchAttributes{ constants.go
366 > CustomSearchAttributes: csa,
367 > }
368 }
369
go.temporal.io/server/common/log/zap_logger.go 38 covered LOC · 10 ranges

Open complete file

82
83 // NewZapLogger returns a new zap based logger from zap.Logger
84 > func NewZapLogger(zl *zap.Logger) *zapLogger { zap_logger.go
85 > return &zapLogger{
86 > zl: zl,
87 > skip: skipForZapLogger,
88 > baseZl: zl,
89 > }
90 > }
91
92 // BuildZapLogger builds and returns a new zap.Logger for this logging configuration
95 }
96
97 > func caller(skip int) string { zap_logger.go
98 > _, path, line, ok := runtime.Caller(skip)
99 > if !ok {
100 return ""
101 }
102 > return path + ":" + strconv.Itoa(line) zap_logger.go
103 }
104
105 > func (l *zapLogger) buildFieldsWithCallAt(tags []tag.Tag) []zap.Field { zap_logger.go
106 > fields := make([]zap.Field, len(tags)+1)
107 > l.fillFields(tags, fields)
108 > fields[len(fields)-1] = zap.String(tag.LoggingCallAtKey, caller(l.skip))
109 > return fields
110 > }
111
112 // fillFields fill fields parameter with fields read from tags. Optimized for performance.
113 > func (l *zapLogger) fillFields(tags []tag.Tag, fields []zap.Field) { zap_logger.go
114 > for i, t := range tags {
115 > if zt, ok := t.(tag.ZapTag); ok { zap_logger.go
116 > fields[i] = zt.Field()
117 > } else {
118 fields[i] = zap.Any(t.Key(), t.Value())
119 }
121 }
122
123 > func setDefaultMsg(msg string) string { zap_logger.go
124 > if msg == "" {
125 return defaultMsgForEmpty
126 }
127 > return msg zap_logger.go
128 }
129
136 }
137
138 > func (l *zapLogger) Info(msg string, tags ...tag.Tag) { zap_logger.go
139 > if l.zl.Core().Enabled(zap.InfoLevel) {
140 > msg = setDefaultMsg(msg)
141 > fields := l.buildFieldsWithCallAt(tags)
142 > l.zl.Info(msg, fields...)
143 > }
144 }
145
211 }
212
213 > func (l *zapLogger) Skip(extraSkip int) Logger { zap_logger.go
214 > return &zapLogger{
215 > zl: l.zl,
216 > skip: l.skip + extraSkip,
217 > baseZl: l.baseZl,
218 > }
219 > }
220
221 func mergeTags(oldTags, newTags []tag.Tag) (outTags []tag.Tag) {
go.temporal.io/server/chasm/context.go 37 covered LOC · 9 ranges

Open complete file

133 ctx context.Context,
134 node *Node,
135 > ) Context { context.go
136 > return newContext(ctx, node)
137 > }
138
139 // newContext creates a new immutableCtx from an existing Context and root Node.
142 ctx context.Context,
143 node *Node,
144 > ) *immutableCtx { context.go
145 > root := node.root()
146 > workflowKey := node.backend.GetWorkflowKey()
147 > return &immutableCtx{
148 > ctx: ctx,
149 > now: root.Now(nil),
150 > root: root,
151 > executionKey: ExecutionKey{
152 > NamespaceID: workflowKey.NamespaceID,
153 > BusinessID: workflowKey.WorkflowID,
154 > RunID: workflowKey.RunID,
155 > },
156 > }
157 > }
158
159 func (c *immutableCtx) Ref(component Component) ([]byte, error) {
173 }
174
175 > func (c *immutableCtx) Now(_ Component) time.Time { context.go
176 > return c.now
177 > }
178
179 func (c *immutableCtx) ExecutionKey() ExecutionKey {
205 }
206
207 > func (c *immutableCtx) Value(key any) any { context.go
208 > if v := c.goContext().Value(key); v != nil {
209 return v
210 }
211
212 > return c.root.registry.componentContextValue(key) context.go
213 }
214
226 }
227
228 > func (c *immutableCtx) NamespaceEntry() *namespace.Namespace { context.go
229 > return c.root.backend.GetNamespaceEntry()
230 > }
231
232 > func (c *immutableCtx) goContext() context.Context { context.go
233 > return c.ctx
234 > }
235
236 func (c *immutableCtx) RequestHeader(key string) string {
256 ctx context.Context,
257 node *Node,
258 > ) MutableContext { context.go
259 > return &mutableCtx{
260 > immutableCtx: newContext(ctx, node),
261 > }
262 > }
263
264 func (c *mutableCtx) AddTask(
266 attributes TaskAttributes,
267 payload any,
268 > ) { context.go
269 > c.root.AddTask(component, attributes, payload)
270 > }
271
272 func (c *mutableCtx) SetRequestLinks(component Component, requestID string, links []*commonpb.Link) error {
go.temporal.io/server/api/adminservice/v1/request_response.pb.go 36 covered LOC · 1 range

Open complete file

6623 }
6624
6625 > func init() { file_temporal_server_api_adminservice_v1_request_response_proto_init() } request_response.pb.go
6626 > func file_temporal_server_api_adminservice_v1_request_response_proto_init() {
6627 > if File_temporal_server_api_adminservice_v1_request_response_proto != nil {
6628 > return
6629 > }
6630 > file_temporal_server_api_adminservice_v1_request_response_proto_msgTypes[59].OneofWrappers = []any{
6631 > (*StreamWorkflowReplicationMessagesRequest_SyncReplicationState)(nil),
6632 > }
6633 > file_temporal_server_api_adminservice_v1_request_response_proto_msgTypes[60].OneofWrappers = []any{
6634 > (*StreamWorkflowReplicationMessagesResponse_Messages)(nil),
6635 > }
6636 > file_temporal_server_api_adminservice_v1_request_response_proto_msgTypes[61].OneofWrappers = []any{
6637 > (*GetNamespaceRequest_Namespace)(nil),
6638 > (*GetNamespaceRequest_Id)(nil),
6639 > }
6640 > file_temporal_server_api_adminservice_v1_request_response_proto_msgTypes[90].OneofWrappers = []any{
6641 > (*StartAdminBatchOperationRequest_RefreshTasksOperation)(nil),
6642 > }
6643 > type x struct{}
6644 > out := protoimpl.TypeBuilder{
6645 > File: protoimpl.DescBuilder{
6646 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
6647 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_adminservice_v1_request_response_proto_rawDesc), len(file_temporal_server_api_adminservice_v1_request_response_proto_rawDesc)),
6648 > NumEnums: 1,
6649 > NumMessages: 105,
6650 > NumExtensions: 0,
6651 > NumServices: 0,
6652 > },
6653 > GoTypes: file_temporal_server_api_adminservice_v1_request_response_proto_goTypes,
6654 > DependencyIndexes: file_temporal_server_api_adminservice_v1_request_response_proto_depIdxs,
6655 > EnumInfos: file_temporal_server_api_adminservice_v1_request_response_proto_enumTypes,
6656 > MessageInfos: file_temporal_server_api_adminservice_v1_request_response_proto_msgTypes,
6657 > }.Build()
6658 > File_temporal_server_api_adminservice_v1_request_response_proto = out.File
6659 > file_temporal_server_api_adminservice_v1_request_response_proto_goTypes = nil
6660 > file_temporal_server_api_adminservice_v1_request_response_proto_depIdxs = nil
6661 }
go.temporal.io/server/api/persistence/v1/chasm_visibility.pb.go 36 covered LOC · 4 ranges

Open complete file

43 func (*ChasmVisibilityData) ProtoMessage() {}
44
45 > func (x *ChasmVisibilityData) ProtoReflect() protoreflect.Message { chasm_visibility.pb.go
46 > mi := &file_temporal_server_api_persistence_v1_chasm_visibility_proto_msgTypes[0]
47 > if x != nil {
48 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
49 > if ms.LoadMessageInfo() == nil {
50 > ms.StoreMessageInfo(mi)
51 > }
52 > return ms
53 }
54 return mi.MessageOf(x)
87 func (*ChasmVisibilityTaskData) ProtoMessage() {}
88
89 > func (x *ChasmVisibilityTaskData) ProtoReflect() protoreflect.Message { chasm_visibility.pb.go
90 > mi := &file_temporal_server_api_persistence_v1_chasm_visibility_proto_msgTypes[1]
91 > if x != nil {
92 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
93 > if ms.LoadMessageInfo() == nil {
94 > ms.StoreMessageInfo(mi)
95 > }
96 > return ms
97 }
98 return mi.MessageOf(x)
146 }
147
148 > func init() { file_temporal_server_api_persistence_v1_chasm_visibility_proto_init() } chasm_visibility.pb.go
149 > func file_temporal_server_api_persistence_v1_chasm_visibility_proto_init() {
150 > if File_temporal_server_api_persistence_v1_chasm_visibility_proto != nil {
151 return
152 }
153 > type x struct{} chasm_visibility.pb.go
154 > out := protoimpl.TypeBuilder{
155 > File: protoimpl.DescBuilder{
156 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
157 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_chasm_visibility_proto_rawDesc), len(file_temporal_server_api_persistence_v1_chasm_visibility_proto_rawDesc)),
158 > NumEnums: 0,
159 > NumMessages: 2,
160 > NumExtensions: 0,
161 > NumServices: 0,
162 > },
163 > GoTypes: file_temporal_server_api_persistence_v1_chasm_visibility_proto_goTypes,
164 > DependencyIndexes: file_temporal_server_api_persistence_v1_chasm_visibility_proto_depIdxs,
165 > MessageInfos: file_temporal_server_api_persistence_v1_chasm_visibility_proto_msgTypes,
166 > }.Build()
167 > File_temporal_server_api_persistence_v1_chasm_visibility_proto = out.File
168 > file_temporal_server_api_persistence_v1_chasm_visibility_proto_goTypes = nil
169 > file_temporal_server_api_persistence_v1_chasm_visibility_proto_depIdxs = nil
170 }
go.temporal.io/server/api/replication/v1/message.pb.go 36 covered LOC · 2 ranges

Open complete file

2441 }
2442
2443 > func init() { file_temporal_server_api_replication_v1_message_proto_init() } message.pb.go
2444 > func file_temporal_server_api_replication_v1_message_proto_init() {
2445 > if File_temporal_server_api_replication_v1_message_proto != nil {
2446 return
2447 }
2448 > file_temporal_server_api_replication_v1_message_proto_msgTypes[0].OneofWrappers = []any{ message.pb.go
2449 > (*ReplicationTask_NamespaceTaskAttributes)(nil),
2450 > (*ReplicationTask_SyncShardStatusTaskAttributes)(nil),
2451 > (*ReplicationTask_SyncActivityTaskAttributes)(nil),
2452 > (*ReplicationTask_HistoryTaskAttributes)(nil),
2453 > (*ReplicationTask_SyncWorkflowStateTaskAttributes)(nil),
2454 > (*ReplicationTask_TaskQueueUserDataAttributes)(nil),
2455 > (*ReplicationTask_SyncHsmAttributes)(nil),
2456 > (*ReplicationTask_BackfillHistoryTaskAttributes)(nil),
2457 > (*ReplicationTask_VerifyVersionedTransitionTaskAttributes)(nil),
2458 > (*ReplicationTask_SyncVersionedTransitionTaskAttributes)(nil),
2459 > }
2460 > file_temporal_server_api_replication_v1_message_proto_msgTypes[21].OneofWrappers = []any{
2461 > (*VersionedTransitionArtifact_SyncWorkflowStateMutationAttributes)(nil),
2462 > (*VersionedTransitionArtifact_SyncWorkflowStateSnapshotAttributes)(nil),
2463 > }
2464 > type x struct{}
2465 > out := protoimpl.TypeBuilder{
2466 > File: protoimpl.DescBuilder{
2467 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
2468 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_replication_v1_message_proto_rawDesc), len(file_temporal_server_api_replication_v1_message_proto_rawDesc)),
2469 > NumEnums: 0,
2470 > NumMessages: 23,
2471 > NumExtensions: 0,
2472 > NumServices: 0,
2473 > },
2474 > GoTypes: file_temporal_server_api_replication_v1_message_proto_goTypes,
2475 > DependencyIndexes: file_temporal_server_api_replication_v1_message_proto_depIdxs,
2476 > MessageInfos: file_temporal_server_api_replication_v1_message_proto_msgTypes,
2477 > }.Build()
2478 > File_temporal_server_api_replication_v1_message_proto = out.File
2479 > file_temporal_server_api_replication_v1_message_proto_goTypes = nil
2480 > file_temporal_server_api_replication_v1_message_proto_depIdxs = nil
2481 }
go.temporal.io/server/chasm/field.go 35 covered LOC · 14 ranges

Open complete file

29 ctx MutableContext,
30 d D,
31 > ) Field[D] { field.go
32 > return Field[D]{
33 > Internal: newFieldInternalWithValue(fieldTypeData, d),
34 > }
35 > }
36
37 func NewComponentField[C Component](
39 c C,
40 options ...ComponentFieldOption,
41 > ) Field[C] { field.go
42 > opts := &componentFieldOptions{}
43 > for _, o := range options {
44 o(opts)
45 }
46 > internal := newFieldInternalWithValue(fieldTypeComponent, c) field.go
47 > internal.detached = opts.detached
48 > return Field[C]{
49 > Internal: internal,
50 > }
51 }
52
80 // Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the
81 // application, even if the error is an application bug.
82 > func (f Field[T]) TryGet(chasmContext Context) (T, bool) { field.go
83 > var nilT T
84 >
85 > // If node is nil, then there is nothing to deserialize from, return value (even if it is also nil).
86 > if f.Internal.node == nil {
87 > if f.Internal.v == nil { field.go
88 return nilT, false
89 }
90 > vT, isT := f.Internal.v.(T) field.go
91 > if !isT {
92 // nolint:forbidigo // Panic is intended here for framework error handling.
93 panic(serviceerror.NewInternalf("internal value doesn't implement %s", reflect.TypeFor[T]().Name()))
94 }
95 > return vT, true field.go
96 }
97
98 > var nodeValue any field.go
99 > switch f.Internal.fieldType() {
100 > case fieldTypeComponent:
101 > if err := f.Internal.node.prepareComponentValue(chasmContext); err != nil {
102 // nolint:forbidigo // Panic is intended here for framework error handling.
103 panic(err)
104 }
105 > nodeValue = f.Internal.node.value field.go
106 case fieldTypeData:
107 // For data fields, T is always a concrete type.
142 }
143
144 > if nodeValue == nil { field.go
145 return nilT, false
146 }
147 > vT, isT := nodeValue.(T) field.go
148 > if !isT {
149 // nolint:forbidigo // Panic is intended here for framework error handling.
150 panic(serviceerror.NewInternalf("node value doesn't implement %s", reflect.TypeFor[T]().Name()))
151 }
152 > return vT, true field.go
153 }
154
156 // Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the
157 // application, even if the error is an application bug.
158 > func (f Field[T]) Get(chasmContext Context) T { field.go
159 > v, ok := f.TryGet(chasmContext)
160 > if !ok {
161 // nolint:forbidigo // Panic is intended here for framework error handling.
162 panic(serviceerror.NewInternalf("field value of type %s not found", reflect.TypeFor[T]().Name()))
163 }
164 > return v field.go
165 }
166
go.temporal.io/server/common/backoff/retrypolicy.go 34 covered LOC · 6 ranges

Open complete file

80
81 // NewExponentialRetryPolicy returns an instance of ExponentialRetryPolicy using the provided initialInterval
82 > func NewExponentialRetryPolicy(initialInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
83 > p := &ExponentialRetryPolicy{
84 > initialInterval: initialInterval,
85 > backoffCoefficient: defaultBackoffCoefficient,
86 > maximumInterval: defaultMaximumInterval,
87 > expirationInterval: defaultExpirationInterval,
88 > maximumAttempts: defaultMaximumAttempts,
89 > }
90 >
91 > return p
92 > }
93
94 // NewRetrier is used for creating a new instance of Retrier
121 // This does *not* cause the policy to stop retrying when the interval between retries reaches the supplied duration.
122 // That is what WithExpirationInterval does. Instead, this prevents the interval from exceeding maximumInterval.
123 > func (p *ExponentialRetryPolicy) WithMaximumInterval(maximumInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
124 > p.maximumInterval = maximumInterval
125 > return p
126 > }
127
128 // WithExpirationInterval sets the absolute expiration interval for all retries
129 > func (p *ExponentialRetryPolicy) WithExpirationInterval(expirationInterval time.Duration) *ExponentialRetryPolicy { retrypolicy.go
130 > p.expirationInterval = expirationInterval
131 > return p
132 > }
133
134 // WithMaximumAttempts sets the maximum number of retry attempts
135 > func (p *ExponentialRetryPolicy) WithMaximumAttempts(maximumAttempts int) *ExponentialRetryPolicy { retrypolicy.go
136 > p.maximumAttempts = maximumAttempts
137 > return p
138 > }
139
140 // ComputeNextDelay returns the next delay interval. This is used by Retrier to delay calling the operation again
267 var _ RetryPolicy = (*ConstantDelayRetryPolicy)(nil)
268
269 > func NewConstantDelayRetryPolicy(delay time.Duration) *ConstantDelayRetryPolicy { retrypolicy.go
270 > return &ConstantDelayRetryPolicy{
271 > maximumAttempts: defaultMaximumAttempts,
272 > jitterPct: defaultJitterPct,
273 > delay: delay,
274 > }
275 > }
276
277 > func (p *ConstantDelayRetryPolicy) WithMaximumAttempts(maximumAttempts int) *ConstantDelayRetryPolicy { retrypolicy.go
278 > p.maximumAttempts = maximumAttempts
279 > return p
280 > }
281
282 func (p *ConstantDelayRetryPolicy) WithJitter(jitterPct float64) *ConstantDelayRetryPolicy {
go.temporal.io/server/common/log/tag/tags.go 33 covered LOC · 11 ranges

Open complete file

70
71 // WorkflowAction returns tag for WorkflowAction
72 > func workflowAction(action string) ZapTag { tags.go
73 > return NewStringTag("wf-action", action)
74 > }
75
76 // WorkflowListFilterType returns tag for WorkflowListFilterType
77 > func workflowListFilterType(listFilterType string) ZapTag { tags.go
78 > return NewStringTag("wf-list-filter-type", listFilterType)
79 > }
80
81 // general
192
193 // WorkflowNamespace returns tag for WorkflowNamespace
194 > func WorkflowNamespace(namespace string) ZapTag { tags.go
195 > return NewStringTag("wf-namespace", namespace)
196 > }
197
198 // WorkflowNamespaceIDs returns tag for WorkflowNamespaceIDs
368
369 // ScheduleID returns tag for ScheduleID
370 > func ScheduleID(scheduleID string) ZapTag { tags.go
371 > return NewStringTag("schedule-id", scheduleID)
372 > }
373
374 // ========== System tags defined here: ==========
376
377 // Component returns tag for Component
378 > func component(component string) ZapTag { tags.go
379 > return NewStringTag("component", component)
380 > }
381
382 // Lifecycle returns tag for Lifecycle
383 > func lifecycle(lifecycle string) ZapTag { tags.go
384 > return NewStringTag("lifecycle", lifecycle)
385 > }
386
387 // StoreOperation returns tag for StoreOperation
388 > func storeOperation(storeOperation string) ZapTag { tags.go
389 > return NewStringTag("store-operation", storeOperation)
390 > }
391
392 // OperationResult returns tag for OperationResult
393 > func operationResult(operationResult string) ZapTag { tags.go
394 > return NewStringTag("operation-result", operationResult)
395 > }
396
397 // ErrorType returns tag for ErrorType
401
402 // errorType returns tag for ErrorType given a string
403 > func errorType(errorType string) ZapTag { tags.go
404 > return NewStringTag("error-type", errorType)
405 > }
406
407 // Shardupdate returns tag for Shardupdate
408 > func shardupdate(shardupdate string) ZapTag { tags.go
409 > return NewStringTag("shard-update", shardupdate)
410 > }
411
412 // scope returns a tag for scope
413 // Pre-defined scope tags are in values.go.
414 > func scope(scope string) ZapTag { tags.go
415 > return NewStringTag("scope", scope)
416 > }
417
418 // general
go.temporal.io/server/api/persistence/v1/update.pb.go 31 covered LOC · 1 range

Open complete file

422 }
423
424 > func init() { file_temporal_server_api_persistence_v1_update_proto_init() } update.pb.go
425 > func file_temporal_server_api_persistence_v1_update_proto_init() {
426 > if File_temporal_server_api_persistence_v1_update_proto != nil {
427 > return
428 > }
429 > file_temporal_server_api_persistence_v1_hsm_proto_init()
430 > file_temporal_server_api_persistence_v1_update_proto_msgTypes[0].OneofWrappers = []any{
431 > (*UpdateAdmissionInfo_HistoryPointer_)(nil),
432 > }
433 > file_temporal_server_api_persistence_v1_update_proto_msgTypes[3].OneofWrappers = []any{
434 > (*UpdateInfo_Acceptance)(nil),
435 > (*UpdateInfo_Completion)(nil),
436 > (*UpdateInfo_Admission)(nil),
437 > }
438 > type x struct{}
439 > out := protoimpl.TypeBuilder{
440 > File: protoimpl.DescBuilder{
441 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
442 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_update_proto_rawDesc), len(file_temporal_server_api_persistence_v1_update_proto_rawDesc)),
443 > NumEnums: 0,
444 > NumMessages: 5,
445 > NumExtensions: 0,
446 > NumServices: 0,
447 > },
448 > GoTypes: file_temporal_server_api_persistence_v1_update_proto_goTypes,
449 > DependencyIndexes: file_temporal_server_api_persistence_v1_update_proto_depIdxs,
450 > MessageInfos: file_temporal_server_api_persistence_v1_update_proto_msgTypes,
451 > }.Build()
452 > File_temporal_server_api_persistence_v1_update_proto = out.File
453 > file_temporal_server_api_persistence_v1_update_proto_goTypes = nil
454 > file_temporal_server_api_persistence_v1_update_proto_depIdxs = nil
455 }
go.temporal.io/server/common/dynamicconfig/deepcopy.go 31 covered LOC · 6 ranges

Open complete file

9 // deepCopyForMapstructure does a simple deep copy of T. Fancy cases (anything other than plain old data)
10 // is not handled and will panic.
11 > func deepCopyForMapstructure[T any](t T) T { deepcopy.go
12 > // nolint:revive // this will be triggered from a static initializer before it can be triggered from production code
13 > return deepCopyValue(reflect.ValueOf(t)).Interface().(T)
14 > }
15
16 > func deepCopyValue(v reflect.Value) reflect.Value { deepcopy.go
17 > switch v.Kind() {
18 case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
19 reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
20 > reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.String: deepcopy.go
21 > nv := reflect.New(v.Type()).Elem()
22 > nv.Set(v)
23 > return nv
24 case reflect.Array:
25 nv := reflect.New(v.Type()).Elem()
42 }
43 return deepCopyValue(v.Elem()).Addr()
44 > case reflect.Slice: deepcopy.go
45 > if v.IsNil() {
46 > return v
47 > }
48 nv := reflect.MakeSlice(v.Type(), v.Len(), v.Len())
49 for i := range v.Len() {
51 }
52 return nv
53 > case reflect.Struct: deepcopy.go
54 > // Special case for time.Time: it has unexported fields so we can't copy it field by
55 > // field, but we can copy zero values (which is all we need for default values).
56 > if v.Type() == reflect.TypeFor[time.Time]() {
57 > if v.Interface().(time.Time).IsZero() {
58 > return reflect.ValueOf(time.Time{})
59 > }
60 // nolint:forbidigo // this will be triggered from a static initializer before it can be triggered from production code
61 panic(fmt.Sprintf("Can't deep copy non-zero time.Time: %v", v.Interface()))
62 }
63 > nv := reflect.New(v.Type()).Elem() deepcopy.go
64 > for i := range v.Type().NumField() {
65 > nv.Field(i).Set(deepCopyValue(v.Field(i)))
66 > }
67 > return nv
68 > case reflect.Interface, reflect.Func, reflect.Chan:
69 > // only nil values of any other reference types allowed!
70 > if v.IsNil() {
71 > return v
72 > }
73 fallthrough
74 default:
go.temporal.io/server/chasm/visibility.go 30 covered LOC · 4 ranges

Open complete file

64
65 // newVisibilitySearchAttributesMapper returns a mapper with all maps initialized.
66 > func newVisibilitySearchAttributesMapper() *VisibilitySearchAttributesMapper { visibility.go
67 > return &VisibilitySearchAttributesMapper{
68 > aliasToField: make(map[string]string),
69 > fieldToAlias: make(map[string]string),
70 > saTypeMap: make(map[string]enumspb.IndexedValueType),
71 > systemAliasToField: make(map[string]string),
72 > overriddenSystemFields: make(map[string]enumspb.IndexedValueType),
73 > }
74 > }
75
76 // Alias returns the alias for a given field.
181 func NewVisibility(
182 mutableContext MutableContext,
183 > ) *Visibility { visibility.go
184 > visibility := &Visibility{
185 > Data: &persistencespb.ChasmVisibilityData{
186 > TransitionCount: 0,
187 > },
188 > }
189 >
190 > visibility.generateTask(mutableContext)
191 > return visibility
192 > }
193
194 func NewVisibilityWithData(
375 func (v *Visibility) generateTask(
376 mutableContext MutableContext,
377 > ) { visibility.go
378 > v.Data.TransitionCount++
379 > mutableContext.AddTask(
380 > v,
381 > TaskAttributes{},
382 > &persistencespb.ChasmVisibilityTaskData{TransitionCount: v.Data.TransitionCount},
383 > )
384 > }
385
386 type visibilityTaskHandler struct {
395 _ TaskInvocation,
396 task *persistencespb.ChasmVisibilityTaskData,
397 > ) (bool, error) { visibility.go
398 > return task.TransitionCount == component.Data.TransitionCount, nil
399 > }
400
401 func (v *visibilityTaskHandler) Execute(
go.temporal.io/server/common/persistence/sql/sqlplugin/mysql/execution_maps.go 30 covered LOC · 5 ranges

Open complete file

53 )
54
55 > func stringMap(a []string, f func(string) string) []string { execution_maps.go
56 > b := make([]string, len(a))
57 > for i, v := range a {
58 > b[i] = f(v)
59 > }
60 > return b
61 }
62
63 > func makeDeleteMapQry(tableName string) string { execution_maps.go
64 > return fmt.Sprintf(deleteMapQryTemplate, tableName)
65 > }
66
67 > func makeSetKeyInMapQry(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
68 > return fmt.Sprintf(setKeyInMapQryTemplate,
69 > tableName,
70 > strings.Join(nonPrimaryKeyColumns, ","),
71 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string {
72 > return ":" + x
73 > }), ","),
74 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string {
75 > return x + "=VALUES(" + x + ")"
76 > }), ","),
77 mapKeyName)
78 }
79
80 > func makeDeleteKeyInMapQry(tableName string, mapKeyName string) string { execution_maps.go
81 > return fmt.Sprintf(deleteKeyInMapQryTemplate,
82 > tableName,
83 > mapKeyName)
84 > }
85
86 > func makeGetMapQryTemplate(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
87 > return fmt.Sprintf(getMapQryTemplate,
88 > tableName,
89 > mapKeyName,
90 > strings.Join(nonPrimaryKeyColumns, ","))
91 > }
92
93 var (
go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/execution_maps.go 30 covered LOC · 6 ranges

Open complete file

86 )
87
88 > func stringMap(a []string, f func(string) string) []string { execution_maps.go
89 > b := make([]string, len(a))
90 > for i, v := range a {
91 > b[i] = f(v)
92 > }
93 > return b
94 }
95
96 > func makeDeleteMapQry(tableName string) string { execution_maps.go
97 > return fmt.Sprintf(deleteMapQueryTemplate, tableName)
98 > }
99
100 > func makeSetKeyInMapQry(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
101 > return fmt.Sprintf(setKeyInMapQueryTemplate,
102 > tableName,
103 > strings.Join(nonPrimaryKeyColumns, ","),
104 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string {
105 > return ":" + x
106 > }), ","),
107 mapKeyName,
108 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string { execution_maps.go
109 > return "excluded." + x
110 > }), ","))
111 }
112
113 > func makeDeleteKeyInMapQry(tableName string, mapKeyName string) string { execution_maps.go
114 > return fmt.Sprintf(deleteKeyInMapQueryTemplate,
115 > tableName,
116 > mapKeyName)
117 > }
118
119 > func makeGetMapQryTemplate(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
120 > return fmt.Sprintf(getMapQueryTemplate,
121 > tableName,
122 > mapKeyName,
123 > strings.Join(nonPrimaryKeyColumns, ","))
124 > }
125
126 var (
go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite/execution_maps.go 30 covered LOC · 5 ranges

Open complete file

52 )
53
54 > func stringMap(a []string, f func(string) string) []string { execution_maps.go
55 > b := make([]string, len(a))
56 > for i, v := range a {
57 > b[i] = f(v)
58 > }
59 > return b
60 }
61
62 > func makeDeleteMapQry(tableName string) string { execution_maps.go
63 > return fmt.Sprintf(deleteMapQryTemplate, tableName)
64 > }
65
66 > func makeSetKeyInMapQry(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
67 > return fmt.Sprintf(setKeyInMapQryTemplate,
68 > tableName,
69 > strings.Join(nonPrimaryKeyColumns, ","),
70 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string {
71 > return ":" + x
72 > }), ","),
73 > strings.Join(stringMap(nonPrimaryKeyColumns, func(x string) string {
74 > return x + "=" + x
75 > }), ","),
76 mapKeyName)
77 }
78
79 > func makeDeleteKeyInMapQry(tableName string, mapKeyName string) string { execution_maps.go
80 > return fmt.Sprintf(deleteKeyInMapQryTemplate,
81 > tableName,
82 > mapKeyName)
83 > }
84
85 > func makeGetMapQryTemplate(tableName string, nonPrimaryKeyColumns []string, mapKeyName string) string { execution_maps.go
86 > return fmt.Sprintf(getMapQryTemplate,
87 > tableName,
88 > mapKeyName,
89 > strings.Join(nonPrimaryKeyColumns, ","))
90 > }
91
92 var (
go.temporal.io/server/api/taskqueue/v1/message.pb.go 29 covered LOC · 2 ranges

Open complete file

1330 }
1331
1332 > func init() { file_temporal_server_api_taskqueue_v1_message_proto_init() } message.pb.go
1333 > func file_temporal_server_api_taskqueue_v1_message_proto_init() {
1334 > if File_temporal_server_api_taskqueue_v1_message_proto != nil {
1335 return
1336 }
1337 > file_temporal_server_api_taskqueue_v1_message_proto_msgTypes[0].OneofWrappers = []any{ message.pb.go
1338 > (*TaskVersionDirective_UseAssignmentRules)(nil),
1339 > (*TaskVersionDirective_AssignedBuildId)(nil),
1340 > }
1341 > file_temporal_server_api_taskqueue_v1_message_proto_msgTypes[5].OneofWrappers = []any{
1342 > (*TaskQueuePartition_NormalPartitionId)(nil),
1343 > (*TaskQueuePartition_StickyName)(nil),
1344 > (*TaskQueuePartition_WorkerCommands)(nil),
1345 > }
1346 > type x struct{}
1347 > out := protoimpl.TypeBuilder{
1348 > File: protoimpl.DescBuilder{
1349 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
1350 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_taskqueue_v1_message_proto_rawDesc), len(file_temporal_server_api_taskqueue_v1_message_proto_rawDesc)),
1351 > NumEnums: 0,
1352 > NumMessages: 16,
1353 > NumExtensions: 0,
1354 > NumServices: 0,
1355 > },
1356 > GoTypes: file_temporal_server_api_taskqueue_v1_message_proto_goTypes,
1357 > DependencyIndexes: file_temporal_server_api_taskqueue_v1_message_proto_depIdxs,
1358 > MessageInfos: file_temporal_server_api_taskqueue_v1_message_proto_msgTypes,
1359 > }.Build()
1360 > File_temporal_server_api_taskqueue_v1_message_proto = out.File
1361 > file_temporal_server_api_taskqueue_v1_message_proto_goTypes = nil
1362 > file_temporal_server_api_taskqueue_v1_message_proto_depIdxs = nil
1363 }
go.temporal.io/server/chasm/field_internal.go 29 covered LOC · 8 ranges

Open complete file

15 }
16
17 > func newFieldInternalWithValue(ft fieldType, v any) fieldInternal { field_internal.go
18 > return fieldInternal{
19 > ft: ft,
20 > v: v,
21 > }
22 > }
23
24 func newFieldInternalWithNode(node *Node) fieldInternal {
28 }
29
30 > func (fi fieldInternal) isEmpty() bool { field_internal.go
31 > return fi.v == nil && fi.node == nil
32 > }
33
34 > func (fi fieldInternal) value() any { field_internal.go
35 > // Deferred pointers are special-cased, since their serialized nodes are
36 > // initialized as regular persistable pointers.
37 > //
38 > // Deferred pointers may have a non-nil node after syncSubComponents, but before
39 > // resolution.
40 > if fi.node == nil || fi.ft == fieldTypeDeferredPointer {
41 > return fi.v field_internal.go
42 > }
43 > return fi.node.value field_internal.go
44 }
45
46 > func (fi fieldInternal) fieldType() fieldType { field_internal.go
47 > // Deferred pointers are special-cased, since their serialized nodes are
48 > // initialized as regular persistable pointers.
49 > //
50 > // Deferred pointers may have a non-nil node after syncSubComponents, but before
51 > // resolution.
52 > if fi.node == nil || fi.ft == fieldTypeDeferredPointer {
53 > return fi.ft field_internal.go
54 > }
55 > return fi.node.fieldType() field_internal.go
56 }
go.temporal.io/server/chasm/lib/scheduler/util.go 29 covered LOC · 7 ranges

Open complete file

26
27 // serializeConflictToken serializes a conflict token as a byte slice.
28 > func serializeConflictToken(conflictToken int64) []byte { util.go
29 > token := make([]byte, 8)
30 > binary.LittleEndian.PutUint64(token, uint64(conflictToken))
31 > return token
32 > }
33
34 // newTaggedLogger returns a logger tagged with the Scheduler's attributes.
35 > func newTaggedLogger(baseLogger log.Logger, scheduler *Scheduler) log.Logger { util.go
36 > return log.With(
37 > baseLogger,
38 > tag.WorkflowNamespace(scheduler.Namespace),
39 > tag.ScheduleID(scheduler.ScheduleId),
40 > )
41 > }
42
43 // newTaggedMetricsHandler returns a metrics handler tagged with the Scheduler's namespace and backend.
44 > func newTaggedMetricsHandler(baseHandler metrics.Handler, scheduler *Scheduler) metrics.Handler { util.go
45 > return baseHandler.WithTags(
46 > metrics.NamespaceTag(scheduler.Namespace),
47 > metrics.StringTag(metrics.ScheduleBackendTag, metrics.ScheduleBackendChasm),
48 > )
49 > }
50
51 // Outcomes for task-lifecycle counters (e.g. ScheduleIdleTask). Mutually
70 lastProcessedTime *timestamppb.Timestamp,
71 scheduledAt time.Time,
72 > ) (bool, error) { util.go
73 > // Immediate tasks are always valid - they execute inline during the transaction.
74 > if scheduledAt.IsZero() {
75 > return true, nil
76 > }
77 // If lastProcessedTime is not set, all scheduled tasks are valid.
78 > if lastProcessedTime == nil || (lastProcessedTime.GetSeconds() == 0 && lastProcessedTime.GetNanos() == 0) { util.go
79 return true, nil
80 }
81 // Scheduled tasks are valid if their time is after the high water mark.
82 > return scheduledAt.After(lastProcessedTime.AsTime()), nil util.go
83 }
84
89 }
90
91 > func (j jsonStringer) String() string { util.go
92 > json, _ := protojson.Marshal(j.Message)
93 > return string(json)
94 > }
go.temporal.io/server/api/schedule/v1/message.pb.go 28 covered LOC · 4 ranges

Open complete file

88 func (*BufferedStart) ProtoMessage() {}
89
90 > func (x *BufferedStart) ProtoReflect() protoreflect.Message { message.pb.go
91 > mi := &file_temporal_server_api_schedule_v1_message_proto_msgTypes[0]
92 > if x != nil {
93 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
94 if ms.LoadMessageInfo() == nil {
97 return ms
98 }
99 > return mi.MessageOf(x) message.pb.go
100 }
101
1224 }
1225
1226 > func init() { file_temporal_server_api_schedule_v1_message_proto_init() } message.pb.go
1227 > func file_temporal_server_api_schedule_v1_message_proto_init() {
1228 > if File_temporal_server_api_schedule_v1_message_proto != nil {
1229 return
1230 }
1231 > file_temporal_server_api_schedule_v1_message_proto_msgTypes[7].OneofWrappers = []any{ message.pb.go
1232 > (*WatchWorkflowResponse_Result)(nil),
1233 > (*WatchWorkflowResponse_Failure)(nil),
1234 > }
1235 > type x struct{}
1236 > out := protoimpl.TypeBuilder{
1237 > File: protoimpl.DescBuilder{
1238 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
1239 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_schedule_v1_message_proto_rawDesc), len(file_temporal_server_api_schedule_v1_message_proto_rawDesc)),
1240 > NumEnums: 0,
1241 > NumMessages: 13,
1242 > NumExtensions: 0,
1243 > NumServices: 0,
1244 > },
1245 > GoTypes: file_temporal_server_api_schedule_v1_message_proto_goTypes,
1246 > DependencyIndexes: file_temporal_server_api_schedule_v1_message_proto_depIdxs,
1247 > MessageInfos: file_temporal_server_api_schedule_v1_message_proto_msgTypes,
1248 > }.Build()
1249 > File_temporal_server_api_schedule_v1_message_proto = out.File
1250 > file_temporal_server_api_schedule_v1_message_proto_goTypes = nil
1251 > file_temporal_server_api_schedule_v1_message_proto_depIdxs = nil
1252 }
go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/tasks.pb.go 28 covered LOC · 3 ranges

Open complete file

131 func (*GeneratorTask) ProtoMessage() {}
132
133 > func (x *GeneratorTask) ProtoReflect() protoreflect.Message { tasks.pb.go
134 > mi := &file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_msgTypes[2]
135 > if x != nil {
136 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
137 > if ms.LoadMessageInfo() == nil {
138 > ms.StoreMessageInfo(mi)
139 > }
140 > return ms
141 }
142 return mi.MessageOf(x)
343 }
344
345 > func init() { file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_init() } tasks.pb.go
346 > func file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_init() {
347 > if File_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto != nil {
348 return
349 }
350 > type x struct{} tasks.pb.go
351 > out := protoimpl.TypeBuilder{
352 > File: protoimpl.DescBuilder{
353 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
354 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_rawDesc), len(file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_rawDesc)),
355 > NumEnums: 0,
356 > NumMessages: 7,
357 > NumExtensions: 0,
358 > NumServices: 0,
359 > },
360 > GoTypes: file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_goTypes,
361 > DependencyIndexes: file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_depIdxs,
362 > MessageInfos: file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_msgTypes,
363 > }.Build()
364 > File_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto = out.File
365 > file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_goTypes = nil
366 > file_temporal_server_chasm_lib_scheduler_proto_v1_tasks_proto_depIdxs = nil
367 }
go.temporal.io/server/common/namespace/namespace.go 26 covered LOC · 8 ranges

Open complete file

81 resolver ReplicationResolver,
82 mutations ...Mutation,
83 > ) (*Namespace, error) { namespace.go
84 > if resolver == nil {
85 return nil, serviceerror.NewInvalidArgument("replicationResolver must be provided")
86 }
87 > ns := &Namespace{ namespace.go
88 > info: detail.Info,
89 > config: detail.Config,
90 > configVersion: detail.ConfigVersion,
91 > customSearchAttributesMapper: CustomSearchAttributesMapper{
92 > fieldToAlias: detail.Config.CustomSearchAttributeAliases,
93 > aliasToField: util.InverseMap(detail.Config.CustomSearchAttributeAliases),
94 > },
95 > replicationResolver: resolver,
96 > }
97 >
98 > for _, m := range mutations {
99 > m.apply(ns) namespace.go
100 > }
101
102 > return ns, nil namespace.go
103 }
104
167
168 // Name observes this namespace's configured name.
169 > func (ns *Namespace) Name() Name { namespace.go
170 > if ns.info == nil {
171 return Name("")
172 }
173 > return Name(ns.info.Name) namespace.go
174 }
175
337 }
338
339 > func (id ID) String() string { namespace.go
340 > return string(id)
341 > }
342
343 func (id ID) IsEmpty() bool {
345 }
346
347 > func (n Name) String() string { namespace.go
348 > return string(n)
349 > }
350
351 func (n Name) IsEmpty() bool {
go.temporal.io/server/common/persistence/serialization/codec.go 25 covered LOC · 10 ranges

Open complete file

26 // encodingTypeFromEnv returns an EncodingType based on the environment variable `TEMPORAL_TEST_DATA_ENCODING`.
27 // It defaults to "ENCODING_TYPE_PROTO3" codec if the environment variable is not set.
28 > func encodingTypeFromEnv() enumspb.EncodingType { codec.go
29 > codecType := os.Getenv(SerializerDataEncodingEnvVar)
30 > switch strings.ToLower(codecType) {
31 > case "", "proto3": codec.go
32 > return enumspb.ENCODING_TYPE_PROTO3
33 case "json":
34 return enumspb.ENCODING_TYPE_JSON
51 // a reliable equality check for any well-formed proto message. For messages
52 // without map fields this is a no-op with no performance overhead.
53 > var WithDeterministicProto3 EncodeOption = func(opts *encodeOptions) { codec.go
54 > opts.deterministic = true
55 > }
56
57 // Encode encodes the given proto message. It respects the `TEMPORAL_TEST_DATA_ENCODING` environment variable;
58 // otherwise, it defaults to "ENCODING_TYPE_PROTO3".
59 > func Encode(m proto.Message, options ...EncodeOption) (*commonpb.DataBlob, error) { codec.go
60 > return encodeBlob(m, encodingTypeFromEnv(), options...)
61 > }
62
63 func encodeBlob(
65 encoding enumspb.EncodingType,
66 options ...EncodeOption,
67 > ) (*commonpb.DataBlob, error) { codec.go
68 > opts := encodeOptions{}
69 > for _, option := range options {
70 > option(&opts) codec.go
71 > }
72
73 > if m == nil { codec.go
74 return &commonpb.DataBlob{
75 Data: nil,
78 }
79
80 > switch encoding { codec.go
81 case enumspb.ENCODING_TYPE_JSON:
82 blob, err := codec.NewJSONPBEncoder().Encode(m)
88 EncodingType: enumspb.ENCODING_TYPE_JSON,
89 }, nil
90 > case enumspb.ENCODING_TYPE_PROTO3: codec.go
91 > data, err := proto.MarshalOptions{Deterministic: opts.deterministic}.Marshal(m)
92 > if err != nil {
93 return nil, NewSerializationError(enumspb.ENCODING_TYPE_PROTO3, err)
94 }
95 > return &commonpb.DataBlob{ codec.go
96 > EncodingType: enumspb.ENCODING_TYPE_PROTO3,
97 > Data: data,
98 > }, nil
99 default:
100 return nil, NewUnknownEncodingTypeError(encoding.String(), enumspb.ENCODING_TYPE_JSON, enumspb.ENCODING_TYPE_PROTO3)
go.temporal.io/server/common/routing/route.go 25 covered LOC · 8 ranges

Open complete file

36
37 // NewRoute returns a new [Route] instance with the given components.
38 > func NewRoute[T any](components ...Component[T]) Route[T] { route.go
39 > return Route[T]{components: components}
40 > }
41
42 // RouteBuilder is a builder for the [Route] interface.
46
47 // NewBuilder creates a new [RouteBuilder] instance, which can be used to define a new [Route] via a fluent API.
48 > func NewBuilder[T any]() *RouteBuilder[T] { route.go
49 > return &RouteBuilder[T]{}
50 > }
51
52 // With adds a series of [Component] instances to the [Route].
53 > func (r *RouteBuilder[T]) With(c ...Component[T]) *RouteBuilder[T] { route.go
54 > r.components = append(r.components, c...)
55 > return r
56 > }
57
58 // Constant adds a [Constant] component to the [Route].
59 > func (r *RouteBuilder[T]) Constant(values ...string) *RouteBuilder[T] { route.go
60 > return r.With(Constant[T](values...))
61 > }
62
63 // StringVariable adds a [StringVariable] component to the [Route].
64 > func (r *RouteBuilder[T]) StringVariable(name string, getter func(*T) *string) *RouteBuilder[T] { route.go
65 > return r.With(StringVariable[T](name, getter))
66 > }
67
68 // Build returns a read-only [Route].
69 > func (r *RouteBuilder[T]) Build() Route[T] { route.go
70 > return NewRoute[T](r.components...)
71 > }
72
73 // Representation returns the [github.com/gorilla/mux] compatible string representation of the route for usage in a
111 // Constant returns a [Component] that represents a series of constant HTTP path components in a Route.
112 // They will be joined via strings when used to construct a path or path representation.
113 > func Constant[T any](values ...string) constant[T] { route.go
114 > return values
115 > }
116
117 type constant[T any] []string
128
129 // StringVariable returns a [Component] that represents a string variable in a Route.
130 > func StringVariable[T any](name string, getter func(*T) *string) stringVariable[T] { route.go
131 > return stringVariable[T]{name, getter}
132 > }
133
134 type stringVariable[T any] struct {
go.temporal.io/server/api/persistence/v1/nexus.pb.go 24 covered LOC · 2 ranges

Open complete file

481 }
482
483 > func init() { file_temporal_server_api_persistence_v1_nexus_proto_init() } nexus.pb.go
484 > func file_temporal_server_api_persistence_v1_nexus_proto_init() {
485 > if File_temporal_server_api_persistence_v1_nexus_proto != nil {
486 return
487 }
488 > file_temporal_server_api_persistence_v1_nexus_proto_msgTypes[1].OneofWrappers = []any{ nexus.pb.go
489 > (*NexusEndpointTarget_Worker_)(nil),
490 > (*NexusEndpointTarget_External_)(nil),
491 > }
492 > type x struct{}
493 > out := protoimpl.TypeBuilder{
494 > File: protoimpl.DescBuilder{
495 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
496 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_nexus_proto_rawDesc), len(file_temporal_server_api_persistence_v1_nexus_proto_rawDesc)),
497 > NumEnums: 0,
498 > NumMessages: 6,
499 > NumExtensions: 0,
500 > NumServices: 0,
501 > },
502 > GoTypes: file_temporal_server_api_persistence_v1_nexus_proto_goTypes,
503 > DependencyIndexes: file_temporal_server_api_persistence_v1_nexus_proto_depIdxs,
504 > MessageInfos: file_temporal_server_api_persistence_v1_nexus_proto_msgTypes,
505 > }.Build()
506 > File_temporal_server_api_persistence_v1_nexus_proto = out.File
507 > file_temporal_server_api_persistence_v1_nexus_proto_goTypes = nil
508 > file_temporal_server_api_persistence_v1_nexus_proto_depIdxs = nil
509 }
go.temporal.io/server/api/persistence/v1/workflow_mutable_state.pb.go 24 covered LOC · 2 ranges

Open complete file

532 }
533
534 > func init() { file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_init() } workflow_mutable_state.pb.go
535 > func file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_init() {
536 > if File_temporal_server_api_persistence_v1_workflow_mutable_state_proto != nil {
537 return
538 }
539 > file_temporal_server_api_persistence_v1_chasm_proto_init() workflow_mutable_state.pb.go
540 > file_temporal_server_api_persistence_v1_executions_proto_init()
541 > file_temporal_server_api_persistence_v1_hsm_proto_init()
542 > file_temporal_server_api_persistence_v1_update_proto_init()
543 > type x struct{}
544 > out := protoimpl.TypeBuilder{
545 > File: protoimpl.DescBuilder{
546 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
547 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_rawDesc), len(file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_rawDesc)),
548 > NumEnums: 0,
549 > NumMessages: 16,
550 > NumExtensions: 0,
551 > NumServices: 0,
552 > },
553 > GoTypes: file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_goTypes,
554 > DependencyIndexes: file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_depIdxs,
555 > MessageInfos: file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_msgTypes,
556 > }.Build()
557 > File_temporal_server_api_persistence_v1_workflow_mutable_state_proto = out.File
558 > file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_goTypes = nil
559 > file_temporal_server_api_persistence_v1_workflow_mutable_state_proto_depIdxs = nil
560 }
go.temporal.io/server/chasm/lib/callback/gen/callbackpb/v1/message.pb.go 24 covered LOC · 2 ranges

Open complete file

462 }
463
464 > func init() { file_temporal_server_chasm_lib_callback_proto_v1_message_proto_init() } message.pb.go
465 > func file_temporal_server_chasm_lib_callback_proto_v1_message_proto_init() {
466 > if File_temporal_server_chasm_lib_callback_proto_v1_message_proto != nil {
467 return
468 }
469 > file_temporal_server_chasm_lib_callback_proto_v1_message_proto_msgTypes[1].OneofWrappers = []any{ message.pb.go
470 > (*Callback_Nexus_)(nil),
471 > }
472 > type x struct{}
473 > out := protoimpl.TypeBuilder{
474 > File: protoimpl.DescBuilder{
475 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
476 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_callback_proto_v1_message_proto_rawDesc), len(file_temporal_server_chasm_lib_callback_proto_v1_message_proto_rawDesc)),
477 > NumEnums: 1,
478 > NumMessages: 5,
479 > NumExtensions: 0,
480 > NumServices: 0,
481 > },
482 > GoTypes: file_temporal_server_chasm_lib_callback_proto_v1_message_proto_goTypes,
483 > DependencyIndexes: file_temporal_server_chasm_lib_callback_proto_v1_message_proto_depIdxs,
484 > EnumInfos: file_temporal_server_chasm_lib_callback_proto_v1_message_proto_enumTypes,
485 > MessageInfos: file_temporal_server_chasm_lib_callback_proto_v1_message_proto_msgTypes,
486 > }.Build()
487 > File_temporal_server_chasm_lib_callback_proto_v1_message_proto = out.File
488 > file_temporal_server_chasm_lib_callback_proto_v1_message_proto_goTypes = nil
489 > file_temporal_server_chasm_lib_callback_proto_v1_message_proto_depIdxs = nil
490 }
go.temporal.io/server/common/log/tag/zap_tag.go 24 covered LOC · 6 ranges

Open complete file

26 }
27
28 > func (t ZapTag) Field() zap.Field { zap_tag.go
29 > return t.field
30 > }
31
32 > func (t ZapTag) Key() string { zap_tag.go
33 > return t.field.Key
34 > }
35
36 func (t ZapTag) Value() any {
44 }
45
46 > func NewStringTag(key string, value string) ZapTag { zap_tag.go
47 > return ZapTag{
48 > field: zap.String(key, value),
49 > }
50 > }
51
52 func NewStringsTag(key string, value []string) ZapTag {
63 // These are still useful if the String() implementation is complicated, especially if
64 // you have lots of Debug-level logs that are ignored in production.
65 > func NewStringerTag(key string, value fmt.Stringer) ZapTag { zap_tag.go
66 > return ZapTag{
67 > field: zap.Stringer(key, value),
68 > }
69 > }
70
71 // NewStringersTag returns a tag that will lazily generate the string representation
118 }
119
120 > func NewBoolTag(key string, value bool) ZapTag { zap_tag.go
121 > return ZapTag{
122 > field: zap.Bool(key, value),
123 > }
124 > }
125
126 func NewErrorTag(key string, value error) ZapTag {
176 }
177
178 > func Stringer(key string, value fmt.Stringer) ZapTag { zap_tag.go
179 > return NewStringerTag(key, value)
180 > }
181
182 func Stringers(key string, value []fmt.Stringer) ZapTag {
go.temporal.io/server/api/enums/v1/predicate.pb.go 23 covered LOC · 3 ranges

Open complete file

111 }
112
113 > func (PredicateType) Descriptor() protoreflect.EnumDescriptor { predicate.pb.go
114 > return file_temporal_server_api_enums_v1_predicate_proto_enumTypes[0].Descriptor()
115 > }
116
117 func (PredicateType) Type() protoreflect.EnumType {
170 }
171
172 > func init() { file_temporal_server_api_enums_v1_predicate_proto_init() } predicate.pb.go
173 > func file_temporal_server_api_enums_v1_predicate_proto_init() {
174 > if File_temporal_server_api_enums_v1_predicate_proto != nil {
175 return
176 }
177 > type x struct{} predicate.pb.go
178 > out := protoimpl.TypeBuilder{
179 > File: protoimpl.DescBuilder{
180 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
181 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_predicate_proto_rawDesc), len(file_temporal_server_api_enums_v1_predicate_proto_rawDesc)),
182 > NumEnums: 1,
183 > NumMessages: 0,
184 > NumExtensions: 0,
185 > NumServices: 0,
186 > },
187 > GoTypes: file_temporal_server_api_enums_v1_predicate_proto_goTypes,
188 > DependencyIndexes: file_temporal_server_api_enums_v1_predicate_proto_depIdxs,
189 > EnumInfos: file_temporal_server_api_enums_v1_predicate_proto_enumTypes,
190 > }.Build()
191 > File_temporal_server_api_enums_v1_predicate_proto = out.File
192 > file_temporal_server_api_enums_v1_predicate_proto_goTypes = nil
193 > file_temporal_server_api_enums_v1_predicate_proto_depIdxs = nil
194 }
go.temporal.io/server/api/enums/v1/task.pb.go 23 covered LOC · 3 ranges

Open complete file

303 }
304
305 > func (TaskType) Descriptor() protoreflect.EnumDescriptor { task.pb.go
306 > return file_temporal_server_api_enums_v1_task_proto_enumTypes[1].Descriptor()
307 > }
308
309 func (TaskType) Type() protoreflect.EnumType {
456 }
457
458 > func init() { file_temporal_server_api_enums_v1_task_proto_init() } task.pb.go
459 > func file_temporal_server_api_enums_v1_task_proto_init() {
460 > if File_temporal_server_api_enums_v1_task_proto != nil {
461 return
462 }
463 > type x struct{} task.pb.go
464 > out := protoimpl.TypeBuilder{
465 > File: protoimpl.DescBuilder{
466 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
467 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_task_proto_rawDesc), len(file_temporal_server_api_enums_v1_task_proto_rawDesc)),
468 > NumEnums: 3,
469 > NumMessages: 0,
470 > NumExtensions: 0,
471 > NumServices: 0,
472 > },
473 > GoTypes: file_temporal_server_api_enums_v1_task_proto_goTypes,
474 > DependencyIndexes: file_temporal_server_api_enums_v1_task_proto_depIdxs,
475 > EnumInfos: file_temporal_server_api_enums_v1_task_proto_enumTypes,
476 > }.Build()
477 > File_temporal_server_api_enums_v1_task_proto = out.File
478 > file_temporal_server_api_enums_v1_task_proto_goTypes = nil
479 > file_temporal_server_api_enums_v1_task_proto_depIdxs = nil
480 }
go.temporal.io/server/api/persistence/v1/queues.pb.go 23 covered LOC · 1 range

Open complete file

616 }
617
618 > func init() { file_temporal_server_api_persistence_v1_queues_proto_init() } queues.pb.go
619 > func file_temporal_server_api_persistence_v1_queues_proto_init() {
620 > if File_temporal_server_api_persistence_v1_queues_proto != nil {
621 > return
622 > }
623 > file_temporal_server_api_persistence_v1_predicates_proto_init()
624 > type x struct{}
625 > out := protoimpl.TypeBuilder{
626 > File: protoimpl.DescBuilder{
627 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
628 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_queues_proto_rawDesc), len(file_temporal_server_api_persistence_v1_queues_proto_rawDesc)),
629 > NumEnums: 0,
630 > NumMessages: 12,
631 > NumExtensions: 0,
632 > NumServices: 0,
633 > },
634 > GoTypes: file_temporal_server_api_persistence_v1_queues_proto_goTypes,
635 > DependencyIndexes: file_temporal_server_api_persistence_v1_queues_proto_depIdxs,
636 > MessageInfos: file_temporal_server_api_persistence_v1_queues_proto_msgTypes,
637 > }.Build()
638 > File_temporal_server_api_persistence_v1_queues_proto = out.File
639 > file_temporal_server_api_persistence_v1_queues_proto_goTypes = nil
640 > file_temporal_server_api_persistence_v1_queues_proto_depIdxs = nil
641 }
go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/request_response.pb.go 23 covered LOC · 1 range

Open complete file

1021 }
1022
1023 > func init() { file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_init() } request_response.pb.go
1024 > func file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_init() {
1025 > if File_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto != nil {
1026 > return
1027 > }
1028 > file_temporal_server_chasm_lib_scheduler_proto_v1_message_proto_init()
1029 > type x struct{}
1030 > out := protoimpl.TypeBuilder{
1031 > File: protoimpl.DescBuilder{
1032 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
1033 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_rawDesc), len(file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_rawDesc)),
1034 > NumEnums: 0,
1035 > NumMessages: 18,
1036 > NumExtensions: 0,
1037 > NumServices: 0,
1038 > },
1039 > GoTypes: file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_goTypes,
1040 > DependencyIndexes: file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_depIdxs,
1041 > MessageInfos: file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_msgTypes,
1042 > }.Build()
1043 > File_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto = out.File
1044 > file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_goTypes = nil
1045 > file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_depIdxs = nil
1046 }
go.temporal.io/server/chasm/lib/scheduler/spec_processor_mock.go 23 covered LOC · 5 ranges

Open complete file

32
33 // NewMockSpecProcessor creates a new mock instance.
34 > func NewMockSpecProcessor(ctrl *gomock.Controller) *MockSpecProcessor { spec_processor_mock.go
35 > mock := &MockSpecProcessor{ctrl: ctrl}
36 > mock.recorder = &MockSpecProcessorMockRecorder{mock}
37 > return mock
38 > }
39
40 // EXPECT returns an object that allows the caller to indicate expected use.
41 > func (m *MockSpecProcessor) EXPECT() *MockSpecProcessorMockRecorder { spec_processor_mock.go
42 > return m.recorder
43 > }
44
45 // NextTime mocks base method.
53
54 // NextTime indicates an expected call of NextTime.
55 > func (mr *MockSpecProcessorMockRecorder) NextTime(arg0, after any) *gomock.Call { spec_processor_mock.go
56 > mr.mock.ctrl.T.Helper()
57 > return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextTime", reflect.TypeOf((*MockSpecProcessor)(nil).NextTime), arg0, after)
58 > }
59
60 // ProcessTimeRange mocks base method.
61 > func (m *MockSpecProcessor) ProcessTimeRange(arg0 *Scheduler, start, end time.Time, overlapPolicy enums.ScheduleOverlapPolicy, workflowID, backfillID string, manual bool, limit *int) (*ProcessedTimeRange, error) { spec_processor_mock.go
62 > m.ctrl.T.Helper()
63 > ret := m.ctrl.Call(m, "ProcessTimeRange", arg0, start, end, overlapPolicy, workflowID, backfillID, manual, limit)
64 > ret0, _ := ret[0].(*ProcessedTimeRange)
65 > ret1, _ := ret[1].(error)
66 > return ret0, ret1
67 > }
68
69 // ProcessTimeRange indicates an expected call of ProcessTimeRange.
70 > func (mr *MockSpecProcessorMockRecorder) ProcessTimeRange(arg0, start, end, overlapPolicy, workflowID, backfillID, manual, limit any) *gomock.Call { spec_processor_mock.go
71 > mr.mock.ctrl.T.Helper()
72 > return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessTimeRange", reflect.TypeOf((*MockSpecProcessor)(nil).ProcessTimeRange), arg0, start, end, overlapPolicy, workflowID, backfillID, manual, limit)
73 > }
go.temporal.io/server/chasm/path_encoder.go 23 covered LOC · 11 ranges

Open complete file

48 node *Node,
49 path []string,
50 > ) (string, error) { path_encoder.go
51 > if path == nil {
52 path = node.path()
53 }
54
55 > if len(path) == 0 { path_encoder.go
56 > return "", nil
57 > }
58
59 > var b strings.Builder path_encoder.go
60 > lastIdx := len(path) - 1
61 > for i, nodeName := range path {
62 > if i > 0 {
63 > if i == lastIdx && path_encoder.go
64 > node.parent != nil &&
65 > node.parent.serializedNode.GetMetadata().GetCollectionAttributes() != nil {
66 _, _ = b.WriteRune(collectionSeparator)
67 > } else { path_encoder.go
68 > _, _ = b.WriteRune(nameSeparator) path_encoder.go
69 > }
70 }
71
72 > if nodeName == "" { path_encoder.go
73 return "", serviceerror.NewInternalf("path contains empty node name: %v", path)
74 }
75
76 > for _, r := range nodeName { path_encoder.go
77 > if r == utf8.RuneError {
78 return "", serviceerror.NewInvalidArgumentf("node name contains invalid UTF-8 code point: %v", nodeName)
79 }
80
81 > if r == escapeChar || path_encoder.go
82 > r == nameSeparator ||
83 > r <= collectionSeparator {
84 _, _ = b.WriteRune(escapeChar)
85 }
86 > _, _ = b.WriteRune(r) path_encoder.go
87 }
88 }
89 > return b.String(), nil path_encoder.go
90 }
91
go.temporal.io/server/common/clock/event_time_source.go 23 covered LOC · 5 ranges

Open complete file

39
40 // NewEventTimeSource returns a EventTimeSource with the current time set to Unix zero: 1970-01-01 00:00:00 +0000 UTC.
41 > func NewEventTimeSource() *EventTimeSource { event_time_source.go
42 > return &EventTimeSource{
43 > now: time.Unix(0, 0),
44 > }
45 > }
46
47 // Some clients depend on the fact that the runtime's timers do _not_ run synchronously.
55
56 // Now return the current time.
57 > func (ts *EventTimeSource) Now() time.Time { event_time_source.go
58 > ts.mu.RLock()
59 > defer ts.mu.RUnlock()
60 >
61 > return ts.now
62 > }
63
64 func (ts *EventTimeSource) Since(t time.Time) time.Duration {
106 // Update the fake current time. It returns the timeSource so that you can chain calls like this:
107 // timeSource := NewEventTimeSource().Update(time.Now())
108 > func (ts *EventTimeSource) Update(now time.Time) *EventTimeSource { event_time_source.go
109 > ts.mu.Lock()
110 > defer ts.mu.Unlock()
111 >
112 > ts.now = now
113 > ts.fireTimers()
114 > return ts
115 > }
116
117 // Advance the timer by the specified duration.
156
157 // fireTimers fires all timers that are ready.
158 > func (ts *EventTimeSource) fireTimers() { event_time_source.go
159 > n := 0
160 > for _, t := range ts.timers {
161 if t.deadline.After(ts.now) {
162 ts.timers[n] = t
go.temporal.io/server/api/common/v1/api_category.pb.go 22 covered LOC · 2 ranges

Open complete file

204 }
205
206 > func init() { file_temporal_server_api_common_v1_api_category_proto_init() } api_category.pb.go
207 > func file_temporal_server_api_common_v1_api_category_proto_init() {
208 > if File_temporal_server_api_common_v1_api_category_proto != nil {
209 return
210 }
211 > type x struct{} api_category.pb.go
212 > out := protoimpl.TypeBuilder{
213 > File: protoimpl.DescBuilder{
214 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
215 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_common_v1_api_category_proto_rawDesc), len(file_temporal_server_api_common_v1_api_category_proto_rawDesc)),
216 > NumEnums: 1,
217 > NumMessages: 1,
218 > NumExtensions: 1,
219 > NumServices: 0,
220 > },
221 > GoTypes: file_temporal_server_api_common_v1_api_category_proto_goTypes,
222 > DependencyIndexes: file_temporal_server_api_common_v1_api_category_proto_depIdxs,
223 > EnumInfos: file_temporal_server_api_common_v1_api_category_proto_enumTypes,
224 > MessageInfos: file_temporal_server_api_common_v1_api_category_proto_msgTypes,
225 > ExtensionInfos: file_temporal_server_api_common_v1_api_category_proto_extTypes,
226 > }.Build()
227 > File_temporal_server_api_common_v1_api_category_proto = out.File
228 > file_temporal_server_api_common_v1_api_category_proto_goTypes = nil
229 > file_temporal_server_api_common_v1_api_category_proto_depIdxs = nil
230 }
go.temporal.io/server/api/persistence/v1/task_queues.pb.go 21 covered LOC · 2 ranges

Open complete file

899 }
900
901 > func init() { file_temporal_server_api_persistence_v1_task_queues_proto_init() } task_queues.pb.go
902 > func file_temporal_server_api_persistence_v1_task_queues_proto_init() {
903 > if File_temporal_server_api_persistence_v1_task_queues_proto != nil {
904 return
905 }
906 > type x struct{} task_queues.pb.go
907 > out := protoimpl.TypeBuilder{
908 > File: protoimpl.DescBuilder{
909 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
910 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_task_queues_proto_rawDesc), len(file_temporal_server_api_persistence_v1_task_queues_proto_rawDesc)),
911 > NumEnums: 1,
912 > NumMessages: 13,
913 > NumExtensions: 0,
914 > NumServices: 0,
915 > },
916 > GoTypes: file_temporal_server_api_persistence_v1_task_queues_proto_goTypes,
917 > DependencyIndexes: file_temporal_server_api_persistence_v1_task_queues_proto_depIdxs,
918 > EnumInfos: file_temporal_server_api_persistence_v1_task_queues_proto_enumTypes,
919 > MessageInfos: file_temporal_server_api_persistence_v1_task_queues_proto_msgTypes,
920 > }.Build()
921 > File_temporal_server_api_persistence_v1_task_queues_proto = out.File
922 > file_temporal_server_api_persistence_v1_task_queues_proto_goTypes = nil
923 > file_temporal_server_api_persistence_v1_task_queues_proto_depIdxs = nil
924 }
go.temporal.io/server/api/routing/v1/extension.pb.go 21 covered LOC · 2 ranges

Open complete file

144 }
145
146 > func init() { file_temporal_server_api_routing_v1_extension_proto_init() } extension.pb.go
147 > func file_temporal_server_api_routing_v1_extension_proto_init() {
148 > if File_temporal_server_api_routing_v1_extension_proto != nil {
149 return
150 }
151 > type x struct{} extension.pb.go
152 > out := protoimpl.TypeBuilder{
153 > File: protoimpl.DescBuilder{
154 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
155 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_routing_v1_extension_proto_rawDesc), len(file_temporal_server_api_routing_v1_extension_proto_rawDesc)),
156 > NumEnums: 0,
157 > NumMessages: 1,
158 > NumExtensions: 1,
159 > NumServices: 0,
160 > },
161 > GoTypes: file_temporal_server_api_routing_v1_extension_proto_goTypes,
162 > DependencyIndexes: file_temporal_server_api_routing_v1_extension_proto_depIdxs,
163 > MessageInfos: file_temporal_server_api_routing_v1_extension_proto_msgTypes,
164 > ExtensionInfos: file_temporal_server_api_routing_v1_extension_proto_extTypes,
165 > }.Build()
166 > File_temporal_server_api_routing_v1_extension_proto = out.File
167 > file_temporal_server_api_routing_v1_extension_proto_goTypes = nil
168 > file_temporal_server_api_routing_v1_extension_proto_depIdxs = nil
169 }
go.temporal.io/server/common/namespace/testconstructors.go 21 covered LOC · 5 ranges

Open complete file

13 config *persistencespb.NamespaceConfig,
14 targetCluster string,
15 > ) *Namespace { testconstructors.go
16 > detail := &persistencespb.NamespaceDetail{
17 > Info: ensureInfo(info),
18 > Config: ensureConfig(config),
19 > ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
20 > ActiveClusterName: targetCluster,
21 > Clusters: []string{targetCluster},
22 > },
23 > FailoverVersion: common.EmptyVersion,
24 > }
25 > factory := NewDefaultReplicationResolverFactory()
26 > resolver := factory(detail)
27 > ns, _ := FromPersistentState(detail, resolver, WithGlobalFlag(false))
28 > return ns
29 > }
30
31 // NewNamespaceForTest returns an entry with test data
68 }
69
70 > func ensureInfo(proto *persistencespb.NamespaceInfo) *persistencespb.NamespaceInfo { testconstructors.go
71 > if proto == nil {
72 return &persistencespb.NamespaceInfo{}
73 }
74 > return proto testconstructors.go
75 }
76
77 > func ensureConfig(proto *persistencespb.NamespaceConfig) *persistencespb.NamespaceConfig { testconstructors.go
78 > if proto == nil {
79 return &persistencespb.NamespaceConfig{}
80 }
81 > return proto testconstructors.go
82 }
83
go.temporal.io/server/api/adminservice/v1/service.pb.go 20 covered LOC · 2 ranges

Open complete file

273 }
274
275 > func init() { file_temporal_server_api_adminservice_v1_service_proto_init() } service.pb.go
276 > func file_temporal_server_api_adminservice_v1_service_proto_init() {
277 > if File_temporal_server_api_adminservice_v1_service_proto != nil {
278 return
279 }
280 > file_temporal_server_api_adminservice_v1_request_response_proto_init() service.pb.go
281 > type x struct{}
282 > out := protoimpl.TypeBuilder{
283 > File: protoimpl.DescBuilder{
284 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
285 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_adminservice_v1_service_proto_rawDesc), len(file_temporal_server_api_adminservice_v1_service_proto_rawDesc)),
286 > NumEnums: 0,
287 > NumMessages: 0,
288 > NumExtensions: 0,
289 > NumServices: 1,
290 > },
291 > GoTypes: file_temporal_server_api_adminservice_v1_service_proto_goTypes,
292 > DependencyIndexes: file_temporal_server_api_adminservice_v1_service_proto_depIdxs,
293 > }.Build()
294 > File_temporal_server_api_adminservice_v1_service_proto = out.File
295 > file_temporal_server_api_adminservice_v1_service_proto_goTypes = nil
296 > file_temporal_server_api_adminservice_v1_service_proto_depIdxs = nil
297 }
go.temporal.io/server/api/archiver/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

431 }
432
433 > func init() { file_temporal_server_api_archiver_v1_message_proto_init() } message.pb.go
434 > func file_temporal_server_api_archiver_v1_message_proto_init() {
435 > if File_temporal_server_api_archiver_v1_message_proto != nil {
436 return
437 }
438 > type x struct{} message.pb.go
439 > out := protoimpl.TypeBuilder{
440 > File: protoimpl.DescBuilder{
441 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
442 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_archiver_v1_message_proto_rawDesc), len(file_temporal_server_api_archiver_v1_message_proto_rawDesc)),
443 > NumEnums: 0,
444 > NumMessages: 4,
445 > NumExtensions: 0,
446 > NumServices: 0,
447 > },
448 > GoTypes: file_temporal_server_api_archiver_v1_message_proto_goTypes,
449 > DependencyIndexes: file_temporal_server_api_archiver_v1_message_proto_depIdxs,
450 > MessageInfos: file_temporal_server_api_archiver_v1_message_proto_msgTypes,
451 > }.Build()
452 > File_temporal_server_api_archiver_v1_message_proto = out.File
453 > file_temporal_server_api_archiver_v1_message_proto_goTypes = nil
454 > file_temporal_server_api_archiver_v1_message_proto_depIdxs = nil
455 }
go.temporal.io/server/api/chasm/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

206 }
207
208 > func init() { file_temporal_server_api_chasm_v1_message_proto_init() } message.pb.go
209 > func file_temporal_server_api_chasm_v1_message_proto_init() {
210 > if File_temporal_server_api_chasm_v1_message_proto != nil {
211 return
212 }
213 > type x struct{} message.pb.go
214 > out := protoimpl.TypeBuilder{
215 > File: protoimpl.DescBuilder{
216 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
217 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_chasm_v1_message_proto_rawDesc), len(file_temporal_server_api_chasm_v1_message_proto_rawDesc)),
218 > NumEnums: 0,
219 > NumMessages: 1,
220 > NumExtensions: 0,
221 > NumServices: 0,
222 > },
223 > GoTypes: file_temporal_server_api_chasm_v1_message_proto_goTypes,
224 > DependencyIndexes: file_temporal_server_api_chasm_v1_message_proto_depIdxs,
225 > MessageInfos: file_temporal_server_api_chasm_v1_message_proto_msgTypes,
226 > }.Build()
227 > File_temporal_server_api_chasm_v1_message_proto = out.File
228 > file_temporal_server_api_chasm_v1_message_proto_goTypes = nil
229 > file_temporal_server_api_chasm_v1_message_proto_depIdxs = nil
230 }
go.temporal.io/server/api/clock/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

193 }
194
195 > func init() { file_temporal_server_api_clock_v1_message_proto_init() } message.pb.go
196 > func file_temporal_server_api_clock_v1_message_proto_init() {
197 > if File_temporal_server_api_clock_v1_message_proto != nil {
198 return
199 }
200 > type x struct{} message.pb.go
201 > out := protoimpl.TypeBuilder{
202 > File: protoimpl.DescBuilder{
203 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
204 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_clock_v1_message_proto_rawDesc), len(file_temporal_server_api_clock_v1_message_proto_rawDesc)),
205 > NumEnums: 0,
206 > NumMessages: 2,
207 > NumExtensions: 0,
208 > NumServices: 0,
209 > },
210 > GoTypes: file_temporal_server_api_clock_v1_message_proto_goTypes,
211 > DependencyIndexes: file_temporal_server_api_clock_v1_message_proto_depIdxs,
212 > MessageInfos: file_temporal_server_api_clock_v1_message_proto_msgTypes,
213 > }.Build()
214 > File_temporal_server_api_clock_v1_message_proto = out.File
215 > file_temporal_server_api_clock_v1_message_proto_goTypes = nil
216 > file_temporal_server_api_clock_v1_message_proto_depIdxs = nil
217 }
go.temporal.io/server/api/cluster/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

342 }
343
344 > func init() { file_temporal_server_api_cluster_v1_message_proto_init() } message.pb.go
345 > func file_temporal_server_api_cluster_v1_message_proto_init() {
346 > if File_temporal_server_api_cluster_v1_message_proto != nil {
347 return
348 }
349 > type x struct{} message.pb.go
350 > out := protoimpl.TypeBuilder{
351 > File: protoimpl.DescBuilder{
352 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
353 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_cluster_v1_message_proto_rawDesc), len(file_temporal_server_api_cluster_v1_message_proto_rawDesc)),
354 > NumEnums: 0,
355 > NumMessages: 4,
356 > NumExtensions: 0,
357 > NumServices: 0,
358 > },
359 > GoTypes: file_temporal_server_api_cluster_v1_message_proto_goTypes,
360 > DependencyIndexes: file_temporal_server_api_cluster_v1_message_proto_depIdxs,
361 > MessageInfos: file_temporal_server_api_cluster_v1_message_proto_msgTypes,
362 > }.Build()
363 > File_temporal_server_api_cluster_v1_message_proto = out.File
364 > file_temporal_server_api_cluster_v1_message_proto_goTypes = nil
365 > file_temporal_server_api_cluster_v1_message_proto_depIdxs = nil
366 }
go.temporal.io/server/api/common/v1/dlq.pb.go 20 covered LOC · 2 ranges

Open complete file

295 }
296
297 > func init() { file_temporal_server_api_common_v1_dlq_proto_init() } dlq.pb.go
298 > func file_temporal_server_api_common_v1_dlq_proto_init() {
299 > if File_temporal_server_api_common_v1_dlq_proto != nil {
300 return
301 }
302 > type x struct{} dlq.pb.go
303 > out := protoimpl.TypeBuilder{
304 > File: protoimpl.DescBuilder{
305 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
306 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_common_v1_dlq_proto_rawDesc), len(file_temporal_server_api_common_v1_dlq_proto_rawDesc)),
307 > NumEnums: 0,
308 > NumMessages: 4,
309 > NumExtensions: 0,
310 > NumServices: 0,
311 > },
312 > GoTypes: file_temporal_server_api_common_v1_dlq_proto_goTypes,
313 > DependencyIndexes: file_temporal_server_api_common_v1_dlq_proto_depIdxs,
314 > MessageInfos: file_temporal_server_api_common_v1_dlq_proto_msgTypes,
315 > }.Build()
316 > File_temporal_server_api_common_v1_dlq_proto = out.File
317 > file_temporal_server_api_common_v1_dlq_proto_goTypes = nil
318 > file_temporal_server_api_common_v1_dlq_proto_depIdxs = nil
319 }
go.temporal.io/server/api/contextpropagation/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

109 }
110
111 > func init() { file_temporal_server_api_contextpropagation_v1_message_proto_init() } message.pb.go
112 > func file_temporal_server_api_contextpropagation_v1_message_proto_init() {
113 > if File_temporal_server_api_contextpropagation_v1_message_proto != nil {
114 return
115 }
116 > type x struct{} message.pb.go
117 > out := protoimpl.TypeBuilder{
118 > File: protoimpl.DescBuilder{
119 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
120 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_contextpropagation_v1_message_proto_rawDesc), len(file_temporal_server_api_contextpropagation_v1_message_proto_rawDesc)),
121 > NumEnums: 0,
122 > NumMessages: 2,
123 > NumExtensions: 0,
124 > NumServices: 0,
125 > },
126 > GoTypes: file_temporal_server_api_contextpropagation_v1_message_proto_goTypes,
127 > DependencyIndexes: file_temporal_server_api_contextpropagation_v1_message_proto_depIdxs,
128 > MessageInfos: file_temporal_server_api_contextpropagation_v1_message_proto_msgTypes,
129 > }.Build()
130 > File_temporal_server_api_contextpropagation_v1_message_proto = out.File
131 > file_temporal_server_api_contextpropagation_v1_message_proto_goTypes = nil
132 > file_temporal_server_api_contextpropagation_v1_message_proto_depIdxs = nil
133 }
go.temporal.io/server/api/deployment/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

4626 }
4627
4628 > func init() { file_temporal_server_api_deployment_v1_message_proto_init() } message.pb.go
4629 > func file_temporal_server_api_deployment_v1_message_proto_init() {
4630 > if File_temporal_server_api_deployment_v1_message_proto != nil {
4631 return
4632 }
4633 > type x struct{} message.pb.go
4634 > out := protoimpl.TypeBuilder{
4635 > File: protoimpl.DescBuilder{
4636 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
4637 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_deployment_v1_message_proto_rawDesc), len(file_temporal_server_api_deployment_v1_message_proto_rawDesc)),
4638 > NumEnums: 0,
4639 > NumMessages: 75,
4640 > NumExtensions: 0,
4641 > NumServices: 0,
4642 > },
4643 > GoTypes: file_temporal_server_api_deployment_v1_message_proto_goTypes,
4644 > DependencyIndexes: file_temporal_server_api_deployment_v1_message_proto_depIdxs,
4645 > MessageInfos: file_temporal_server_api_deployment_v1_message_proto_msgTypes,
4646 > }.Build()
4647 > File_temporal_server_api_deployment_v1_message_proto = out.File
4648 > file_temporal_server_api_deployment_v1_message_proto_goTypes = nil
4649 > file_temporal_server_api_deployment_v1_message_proto_depIdxs = nil
4650 }
go.temporal.io/server/api/enums/v1/cluster.pb.go 20 covered LOC · 2 ranges

Open complete file

209 }
210
211 > func init() { file_temporal_server_api_enums_v1_cluster_proto_init() } cluster.pb.go
212 > func file_temporal_server_api_enums_v1_cluster_proto_init() {
213 > if File_temporal_server_api_enums_v1_cluster_proto != nil {
214 return
215 }
216 > type x struct{} cluster.pb.go
217 > out := protoimpl.TypeBuilder{
218 > File: protoimpl.DescBuilder{
219 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
220 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_cluster_proto_rawDesc), len(file_temporal_server_api_enums_v1_cluster_proto_rawDesc)),
221 > NumEnums: 2,
222 > NumMessages: 0,
223 > NumExtensions: 0,
224 > NumServices: 0,
225 > },
226 > GoTypes: file_temporal_server_api_enums_v1_cluster_proto_goTypes,
227 > DependencyIndexes: file_temporal_server_api_enums_v1_cluster_proto_depIdxs,
228 > EnumInfos: file_temporal_server_api_enums_v1_cluster_proto_enumTypes,
229 > }.Build()
230 > File_temporal_server_api_enums_v1_cluster_proto = out.File
231 > file_temporal_server_api_enums_v1_cluster_proto_goTypes = nil
232 > file_temporal_server_api_enums_v1_cluster_proto_depIdxs = nil
233 }
go.temporal.io/server/api/enums/v1/common.pb.go 20 covered LOC · 2 ranges

Open complete file

264 }
265
266 > func init() { file_temporal_server_api_enums_v1_common_proto_init() } common.pb.go
267 > func file_temporal_server_api_enums_v1_common_proto_init() {
268 > if File_temporal_server_api_enums_v1_common_proto != nil {
269 return
270 }
271 > type x struct{} common.pb.go
272 > out := protoimpl.TypeBuilder{
273 > File: protoimpl.DescBuilder{
274 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
275 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_common_proto_rawDesc), len(file_temporal_server_api_enums_v1_common_proto_rawDesc)),
276 > NumEnums: 3,
277 > NumMessages: 0,
278 > NumExtensions: 0,
279 > NumServices: 0,
280 > },
281 > GoTypes: file_temporal_server_api_enums_v1_common_proto_goTypes,
282 > DependencyIndexes: file_temporal_server_api_enums_v1_common_proto_depIdxs,
283 > EnumInfos: file_temporal_server_api_enums_v1_common_proto_enumTypes,
284 > }.Build()
285 > File_temporal_server_api_enums_v1_common_proto = out.File
286 > file_temporal_server_api_enums_v1_common_proto_goTypes = nil
287 > file_temporal_server_api_enums_v1_common_proto_depIdxs = nil
288 }
go.temporal.io/server/api/enums/v1/dlq.pb.go 20 covered LOC · 2 ranges

Open complete file

187 }
188
189 > func init() { file_temporal_server_api_enums_v1_dlq_proto_init() } dlq.pb.go
190 > func file_temporal_server_api_enums_v1_dlq_proto_init() {
191 > if File_temporal_server_api_enums_v1_dlq_proto != nil {
192 return
193 }
194 > type x struct{} dlq.pb.go
195 > out := protoimpl.TypeBuilder{
196 > File: protoimpl.DescBuilder{
197 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
198 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_dlq_proto_rawDesc), len(file_temporal_server_api_enums_v1_dlq_proto_rawDesc)),
199 > NumEnums: 2,
200 > NumMessages: 0,
201 > NumExtensions: 0,
202 > NumServices: 0,
203 > },
204 > GoTypes: file_temporal_server_api_enums_v1_dlq_proto_goTypes,
205 > DependencyIndexes: file_temporal_server_api_enums_v1_dlq_proto_depIdxs,
206 > EnumInfos: file_temporal_server_api_enums_v1_dlq_proto_enumTypes,
207 > }.Build()
208 > File_temporal_server_api_enums_v1_dlq_proto = out.File
209 > file_temporal_server_api_enums_v1_dlq_proto_goTypes = nil
210 > file_temporal_server_api_enums_v1_dlq_proto_depIdxs = nil
211 }
go.temporal.io/server/api/enums/v1/fairness_state.pb.go 20 covered LOC · 2 ranges

Open complete file

123 }
124
125 > func init() { file_temporal_server_api_enums_v1_fairness_state_proto_init() } fairness_state.pb.go
126 > func file_temporal_server_api_enums_v1_fairness_state_proto_init() {
127 > if File_temporal_server_api_enums_v1_fairness_state_proto != nil {
128 return
129 }
130 > type x struct{} fairness_state.pb.go
131 > out := protoimpl.TypeBuilder{
132 > File: protoimpl.DescBuilder{
133 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
134 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_fairness_state_proto_rawDesc), len(file_temporal_server_api_enums_v1_fairness_state_proto_rawDesc)),
135 > NumEnums: 1,
136 > NumMessages: 0,
137 > NumExtensions: 0,
138 > NumServices: 0,
139 > },
140 > GoTypes: file_temporal_server_api_enums_v1_fairness_state_proto_goTypes,
141 > DependencyIndexes: file_temporal_server_api_enums_v1_fairness_state_proto_depIdxs,
142 > EnumInfos: file_temporal_server_api_enums_v1_fairness_state_proto_enumTypes,
143 > }.Build()
144 > File_temporal_server_api_enums_v1_fairness_state_proto = out.File
145 > file_temporal_server_api_enums_v1_fairness_state_proto_goTypes = nil
146 > file_temporal_server_api_enums_v1_fairness_state_proto_depIdxs = nil
147 }
go.temporal.io/server/api/enums/v1/nexus.pb.go 20 covered LOC · 2 ranges

Open complete file

158 }
159
160 > func init() { file_temporal_server_api_enums_v1_nexus_proto_init() } nexus.pb.go
161 > func file_temporal_server_api_enums_v1_nexus_proto_init() {
162 > if File_temporal_server_api_enums_v1_nexus_proto != nil {
163 return
164 }
165 > type x struct{} nexus.pb.go
166 > out := protoimpl.TypeBuilder{
167 > File: protoimpl.DescBuilder{
168 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
169 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_nexus_proto_rawDesc), len(file_temporal_server_api_enums_v1_nexus_proto_rawDesc)),
170 > NumEnums: 1,
171 > NumMessages: 0,
172 > NumExtensions: 0,
173 > NumServices: 0,
174 > },
175 > GoTypes: file_temporal_server_api_enums_v1_nexus_proto_goTypes,
176 > DependencyIndexes: file_temporal_server_api_enums_v1_nexus_proto_depIdxs,
177 > EnumInfos: file_temporal_server_api_enums_v1_nexus_proto_enumTypes,
178 > }.Build()
179 > File_temporal_server_api_enums_v1_nexus_proto = out.File
180 > file_temporal_server_api_enums_v1_nexus_proto_goTypes = nil
181 > file_temporal_server_api_enums_v1_nexus_proto_depIdxs = nil
182 }
go.temporal.io/server/api/enums/v1/replication.pb.go 20 covered LOC · 2 ranges

Open complete file

314 }
315
316 > func init() { file_temporal_server_api_enums_v1_replication_proto_init() } replication.pb.go
317 > func file_temporal_server_api_enums_v1_replication_proto_init() {
318 > if File_temporal_server_api_enums_v1_replication_proto != nil {
319 return
320 }
321 > type x struct{} replication.pb.go
322 > out := protoimpl.TypeBuilder{
323 > File: protoimpl.DescBuilder{
324 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
325 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_replication_proto_rawDesc), len(file_temporal_server_api_enums_v1_replication_proto_rawDesc)),
326 > NumEnums: 3,
327 > NumMessages: 0,
328 > NumExtensions: 0,
329 > NumServices: 0,
330 > },
331 > GoTypes: file_temporal_server_api_enums_v1_replication_proto_goTypes,
332 > DependencyIndexes: file_temporal_server_api_enums_v1_replication_proto_depIdxs,
333 > EnumInfos: file_temporal_server_api_enums_v1_replication_proto_enumTypes,
334 > }.Build()
335 > File_temporal_server_api_enums_v1_replication_proto = out.File
336 > file_temporal_server_api_enums_v1_replication_proto_goTypes = nil
337 > file_temporal_server_api_enums_v1_replication_proto_depIdxs = nil
338 }
go.temporal.io/server/api/enums/v1/workflow.pb.go 20 covered LOC · 2 ranges

Open complete file

275 }
276
277 > func init() { file_temporal_server_api_enums_v1_workflow_proto_init() } workflow.pb.go
278 > func file_temporal_server_api_enums_v1_workflow_proto_init() {
279 > if File_temporal_server_api_enums_v1_workflow_proto != nil {
280 return
281 }
282 > type x struct{} workflow.pb.go
283 > out := protoimpl.TypeBuilder{
284 > File: protoimpl.DescBuilder{
285 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
286 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_workflow_proto_rawDesc), len(file_temporal_server_api_enums_v1_workflow_proto_rawDesc)),
287 > NumEnums: 3,
288 > NumMessages: 0,
289 > NumExtensions: 0,
290 > NumServices: 0,
291 > },
292 > GoTypes: file_temporal_server_api_enums_v1_workflow_proto_goTypes,
293 > DependencyIndexes: file_temporal_server_api_enums_v1_workflow_proto_depIdxs,
294 > EnumInfos: file_temporal_server_api_enums_v1_workflow_proto_enumTypes,
295 > }.Build()
296 > File_temporal_server_api_enums_v1_workflow_proto = out.File
297 > file_temporal_server_api_enums_v1_workflow_proto_goTypes = nil
298 > file_temporal_server_api_enums_v1_workflow_proto_depIdxs = nil
299 }
go.temporal.io/server/api/enums/v1/workflow_task_type.pb.go 20 covered LOC · 2 ranges

Open complete file

124 }
125
126 > func init() { file_temporal_server_api_enums_v1_workflow_task_type_proto_init() } workflow_task_type.pb.go
127 > func file_temporal_server_api_enums_v1_workflow_task_type_proto_init() {
128 > if File_temporal_server_api_enums_v1_workflow_task_type_proto != nil {
129 return
130 }
131 > type x struct{} workflow_task_type.pb.go
132 > out := protoimpl.TypeBuilder{
133 > File: protoimpl.DescBuilder{
134 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
135 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_enums_v1_workflow_task_type_proto_rawDesc), len(file_temporal_server_api_enums_v1_workflow_task_type_proto_rawDesc)),
136 > NumEnums: 1,
137 > NumMessages: 0,
138 > NumExtensions: 0,
139 > NumServices: 0,
140 > },
141 > GoTypes: file_temporal_server_api_enums_v1_workflow_task_type_proto_goTypes,
142 > DependencyIndexes: file_temporal_server_api_enums_v1_workflow_task_type_proto_depIdxs,
143 > EnumInfos: file_temporal_server_api_enums_v1_workflow_task_type_proto_enumTypes,
144 > }.Build()
145 > File_temporal_server_api_enums_v1_workflow_task_type_proto = out.File
146 > file_temporal_server_api_enums_v1_workflow_task_type_proto_goTypes = nil
147 > file_temporal_server_api_enums_v1_workflow_task_type_proto_depIdxs = nil
148 }
go.temporal.io/server/api/errordetails/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

625 }
626
627 > func init() { file_temporal_server_api_errordetails_v1_message_proto_init() } message.pb.go
628 > func file_temporal_server_api_errordetails_v1_message_proto_init() {
629 > if File_temporal_server_api_errordetails_v1_message_proto != nil {
630 return
631 }
632 > type x struct{} message.pb.go
633 > out := protoimpl.TypeBuilder{
634 > File: protoimpl.DescBuilder{
635 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
636 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_errordetails_v1_message_proto_rawDesc), len(file_temporal_server_api_errordetails_v1_message_proto_rawDesc)),
637 > NumEnums: 0,
638 > NumMessages: 10,
639 > NumExtensions: 0,
640 > NumServices: 0,
641 > },
642 > GoTypes: file_temporal_server_api_errordetails_v1_message_proto_goTypes,
643 > DependencyIndexes: file_temporal_server_api_errordetails_v1_message_proto_depIdxs,
644 > MessageInfos: file_temporal_server_api_errordetails_v1_message_proto_msgTypes,
645 > }.Build()
646 > File_temporal_server_api_errordetails_v1_message_proto = out.File
647 > file_temporal_server_api_errordetails_v1_message_proto_goTypes = nil
648 > file_temporal_server_api_errordetails_v1_message_proto_depIdxs = nil
649 }
go.temporal.io/server/api/health/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

300 }
301
302 > func init() { file_temporal_server_api_health_v1_message_proto_init() } message.pb.go
303 > func file_temporal_server_api_health_v1_message_proto_init() {
304 > if File_temporal_server_api_health_v1_message_proto != nil {
305 return
306 }
307 > type x struct{} message.pb.go
308 > out := protoimpl.TypeBuilder{
309 > File: protoimpl.DescBuilder{
310 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
311 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_health_v1_message_proto_rawDesc), len(file_temporal_server_api_health_v1_message_proto_rawDesc)),
312 > NumEnums: 0,
313 > NumMessages: 3,
314 > NumExtensions: 0,
315 > NumServices: 0,
316 > },
317 > GoTypes: file_temporal_server_api_health_v1_message_proto_goTypes,
318 > DependencyIndexes: file_temporal_server_api_health_v1_message_proto_depIdxs,
319 > MessageInfos: file_temporal_server_api_health_v1_message_proto_msgTypes,
320 > }.Build()
321 > File_temporal_server_api_health_v1_message_proto = out.File
322 > file_temporal_server_api_health_v1_message_proto_goTypes = nil
323 > file_temporal_server_api_health_v1_message_proto_depIdxs = nil
324 }
go.temporal.io/server/api/history/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

498 }
499
500 > func init() { file_temporal_server_api_history_v1_message_proto_init() } message.pb.go
501 > func file_temporal_server_api_history_v1_message_proto_init() {
502 > if File_temporal_server_api_history_v1_message_proto != nil {
503 return
504 }
505 > type x struct{} message.pb.go
506 > out := protoimpl.TypeBuilder{
507 > File: protoimpl.DescBuilder{
508 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
509 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_history_v1_message_proto_rawDesc), len(file_temporal_server_api_history_v1_message_proto_rawDesc)),
510 > NumEnums: 0,
511 > NumMessages: 8,
512 > NumExtensions: 0,
513 > NumServices: 0,
514 > },
515 > GoTypes: file_temporal_server_api_history_v1_message_proto_goTypes,
516 > DependencyIndexes: file_temporal_server_api_history_v1_message_proto_depIdxs,
517 > MessageInfos: file_temporal_server_api_history_v1_message_proto_msgTypes,
518 > }.Build()
519 > File_temporal_server_api_history_v1_message_proto = out.File
520 > file_temporal_server_api_history_v1_message_proto_goTypes = nil
521 > file_temporal_server_api_history_v1_message_proto_depIdxs = nil
522 }
go.temporal.io/server/api/historyservice/v1/service.pb.go 20 covered LOC · 2 ranges

Open complete file

428 }
429
430 > func init() { file_temporal_server_api_historyservice_v1_service_proto_init() } service.pb.go
431 > func file_temporal_server_api_historyservice_v1_service_proto_init() {
432 > if File_temporal_server_api_historyservice_v1_service_proto != nil {
433 return
434 }
435 > file_temporal_server_api_historyservice_v1_request_response_proto_init() service.pb.go
436 > type x struct{}
437 > out := protoimpl.TypeBuilder{
438 > File: protoimpl.DescBuilder{
439 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
440 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_historyservice_v1_service_proto_rawDesc), len(file_temporal_server_api_historyservice_v1_service_proto_rawDesc)),
441 > NumEnums: 0,
442 > NumMessages: 0,
443 > NumExtensions: 0,
444 > NumServices: 1,
445 > },
446 > GoTypes: file_temporal_server_api_historyservice_v1_service_proto_goTypes,
447 > DependencyIndexes: file_temporal_server_api_historyservice_v1_service_proto_depIdxs,
448 > }.Build()
449 > File_temporal_server_api_historyservice_v1_service_proto = out.File
450 > file_temporal_server_api_historyservice_v1_service_proto_goTypes = nil
451 > file_temporal_server_api_historyservice_v1_service_proto_depIdxs = nil
452 }
go.temporal.io/server/api/matchingservice/v1/service.pb.go 20 covered LOC · 2 ranges

Open complete file

250 }
251
252 > func init() { file_temporal_server_api_matchingservice_v1_service_proto_init() } service.pb.go
253 > func file_temporal_server_api_matchingservice_v1_service_proto_init() {
254 > if File_temporal_server_api_matchingservice_v1_service_proto != nil {
255 return
256 }
257 > file_temporal_server_api_matchingservice_v1_request_response_proto_init() service.pb.go
258 > type x struct{}
259 > out := protoimpl.TypeBuilder{
260 > File: protoimpl.DescBuilder{
261 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
262 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_matchingservice_v1_service_proto_rawDesc), len(file_temporal_server_api_matchingservice_v1_service_proto_rawDesc)),
263 > NumEnums: 0,
264 > NumMessages: 0,
265 > NumExtensions: 0,
266 > NumServices: 1,
267 > },
268 > GoTypes: file_temporal_server_api_matchingservice_v1_service_proto_goTypes,
269 > DependencyIndexes: file_temporal_server_api_matchingservice_v1_service_proto_depIdxs,
270 > }.Build()
271 > File_temporal_server_api_matchingservice_v1_service_proto = out.File
272 > file_temporal_server_api_matchingservice_v1_service_proto_goTypes = nil
273 > file_temporal_server_api_matchingservice_v1_service_proto_depIdxs = nil
274 }
go.temporal.io/server/api/metrics/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

104 }
105
106 > func init() { file_temporal_server_api_metrics_v1_message_proto_init() } message.pb.go
107 > func file_temporal_server_api_metrics_v1_message_proto_init() {
108 > if File_temporal_server_api_metrics_v1_message_proto != nil {
109 return
110 }
111 > type x struct{} message.pb.go
112 > out := protoimpl.TypeBuilder{
113 > File: protoimpl.DescBuilder{
114 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
115 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_metrics_v1_message_proto_rawDesc), len(file_temporal_server_api_metrics_v1_message_proto_rawDesc)),
116 > NumEnums: 0,
117 > NumMessages: 2,
118 > NumExtensions: 0,
119 > NumServices: 0,
120 > },
121 > GoTypes: file_temporal_server_api_metrics_v1_message_proto_goTypes,
122 > DependencyIndexes: file_temporal_server_api_metrics_v1_message_proto_depIdxs,
123 > MessageInfos: file_temporal_server_api_metrics_v1_message_proto_msgTypes,
124 > }.Build()
125 > File_temporal_server_api_metrics_v1_message_proto = out.File
126 > file_temporal_server_api_metrics_v1_message_proto_goTypes = nil
127 > file_temporal_server_api_metrics_v1_message_proto_depIdxs = nil
128 }
go.temporal.io/server/api/namespace/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

114 }
115
116 > func init() { file_temporal_server_api_namespace_v1_message_proto_init() } message.pb.go
117 > func file_temporal_server_api_namespace_v1_message_proto_init() {
118 > if File_temporal_server_api_namespace_v1_message_proto != nil {
119 return
120 }
121 > type x struct{} message.pb.go
122 > out := protoimpl.TypeBuilder{
123 > File: protoimpl.DescBuilder{
124 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
125 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_namespace_v1_message_proto_rawDesc), len(file_temporal_server_api_namespace_v1_message_proto_rawDesc)),
126 > NumEnums: 0,
127 > NumMessages: 1,
128 > NumExtensions: 0,
129 > NumServices: 0,
130 > },
131 > GoTypes: file_temporal_server_api_namespace_v1_message_proto_goTypes,
132 > DependencyIndexes: file_temporal_server_api_namespace_v1_message_proto_depIdxs,
133 > MessageInfos: file_temporal_server_api_namespace_v1_message_proto_msgTypes,
134 > }.Build()
135 > File_temporal_server_api_namespace_v1_message_proto = out.File
136 > file_temporal_server_api_namespace_v1_message_proto_goTypes = nil
137 > file_temporal_server_api_namespace_v1_message_proto_depIdxs = nil
138 }
go.temporal.io/server/api/persistence/v1/cluster_metadata.pb.go 20 covered LOC · 2 ranges

Open complete file

289 }
290
291 > func init() { file_temporal_server_api_persistence_v1_cluster_metadata_proto_init() } cluster_metadata.pb.go
292 > func file_temporal_server_api_persistence_v1_cluster_metadata_proto_init() {
293 > if File_temporal_server_api_persistence_v1_cluster_metadata_proto != nil {
294 return
295 }
296 > type x struct{} cluster_metadata.pb.go
297 > out := protoimpl.TypeBuilder{
298 > File: protoimpl.DescBuilder{
299 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
300 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc), len(file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc)),
301 > NumEnums: 0,
302 > NumMessages: 5,
303 > NumExtensions: 0,
304 > NumServices: 0,
305 > },
306 > GoTypes: file_temporal_server_api_persistence_v1_cluster_metadata_proto_goTypes,
307 > DependencyIndexes: file_temporal_server_api_persistence_v1_cluster_metadata_proto_depIdxs,
308 > MessageInfos: file_temporal_server_api_persistence_v1_cluster_metadata_proto_msgTypes,
309 > }.Build()
310 > File_temporal_server_api_persistence_v1_cluster_metadata_proto = out.File
311 > file_temporal_server_api_persistence_v1_cluster_metadata_proto_goTypes = nil
312 > file_temporal_server_api_persistence_v1_cluster_metadata_proto_depIdxs = nil
313 }
go.temporal.io/server/api/persistence/v1/history_tree.pb.go 20 covered LOC · 2 ranges

Open complete file

274 }
275
276 > func init() { file_temporal_server_api_persistence_v1_history_tree_proto_init() } history_tree.pb.go
277 > func file_temporal_server_api_persistence_v1_history_tree_proto_init() {
278 > if File_temporal_server_api_persistence_v1_history_tree_proto != nil {
279 return
280 }
281 > type x struct{} history_tree.pb.go
282 > out := protoimpl.TypeBuilder{
283 > File: protoimpl.DescBuilder{
284 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
285 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_history_tree_proto_rawDesc), len(file_temporal_server_api_persistence_v1_history_tree_proto_rawDesc)),
286 > NumEnums: 0,
287 > NumMessages: 3,
288 > NumExtensions: 0,
289 > NumServices: 0,
290 > },
291 > GoTypes: file_temporal_server_api_persistence_v1_history_tree_proto_goTypes,
292 > DependencyIndexes: file_temporal_server_api_persistence_v1_history_tree_proto_depIdxs,
293 > MessageInfos: file_temporal_server_api_persistence_v1_history_tree_proto_msgTypes,
294 > }.Build()
295 > File_temporal_server_api_persistence_v1_history_tree_proto = out.File
296 > file_temporal_server_api_persistence_v1_history_tree_proto_goTypes = nil
297 > file_temporal_server_api_persistence_v1_history_tree_proto_depIdxs = nil
298 }
go.temporal.io/server/api/persistence/v1/namespaces.pb.go 20 covered LOC · 2 ranges

Open complete file

536 }
537
538 > func init() { file_temporal_server_api_persistence_v1_namespaces_proto_init() } namespaces.pb.go
539 > func file_temporal_server_api_persistence_v1_namespaces_proto_init() {
540 > if File_temporal_server_api_persistence_v1_namespaces_proto != nil {
541 return
542 }
543 > type x struct{} namespaces.pb.go
544 > out := protoimpl.TypeBuilder{
545 > File: protoimpl.DescBuilder{
546 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
547 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_namespaces_proto_rawDesc), len(file_temporal_server_api_persistence_v1_namespaces_proto_rawDesc)),
548 > NumEnums: 0,
549 > NumMessages: 8,
550 > NumExtensions: 0,
551 > NumServices: 0,
552 > },
553 > GoTypes: file_temporal_server_api_persistence_v1_namespaces_proto_goTypes,
554 > DependencyIndexes: file_temporal_server_api_persistence_v1_namespaces_proto_depIdxs,
555 > MessageInfos: file_temporal_server_api_persistence_v1_namespaces_proto_msgTypes,
556 > }.Build()
557 > File_temporal_server_api_persistence_v1_namespaces_proto = out.File
558 > file_temporal_server_api_persistence_v1_namespaces_proto_goTypes = nil
559 > file_temporal_server_api_persistence_v1_namespaces_proto_depIdxs = nil
560 }
go.temporal.io/server/api/persistence/v1/queue_metadata.pb.go 20 covered LOC · 2 ranges

Open complete file

105 }
106
107 > func init() { file_temporal_server_api_persistence_v1_queue_metadata_proto_init() } queue_metadata.pb.go
108 > func file_temporal_server_api_persistence_v1_queue_metadata_proto_init() {
109 > if File_temporal_server_api_persistence_v1_queue_metadata_proto != nil {
110 return
111 }
112 > type x struct{} queue_metadata.pb.go
113 > out := protoimpl.TypeBuilder{
114 > File: protoimpl.DescBuilder{
115 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
116 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_queue_metadata_proto_rawDesc), len(file_temporal_server_api_persistence_v1_queue_metadata_proto_rawDesc)),
117 > NumEnums: 0,
118 > NumMessages: 2,
119 > NumExtensions: 0,
120 > NumServices: 0,
121 > },
122 > GoTypes: file_temporal_server_api_persistence_v1_queue_metadata_proto_goTypes,
123 > DependencyIndexes: file_temporal_server_api_persistence_v1_queue_metadata_proto_depIdxs,
124 > MessageInfos: file_temporal_server_api_persistence_v1_queue_metadata_proto_msgTypes,
125 > }.Build()
126 > File_temporal_server_api_persistence_v1_queue_metadata_proto = out.File
127 > file_temporal_server_api_persistence_v1_queue_metadata_proto_goTypes = nil
128 > file_temporal_server_api_persistence_v1_queue_metadata_proto_depIdxs = nil
129 }
go.temporal.io/server/api/persistence/v1/tasks.pb.go 20 covered LOC · 2 ranges

Open complete file

846 }
847
848 > func init() { file_temporal_server_api_persistence_v1_tasks_proto_init() } tasks.pb.go
849 > func file_temporal_server_api_persistence_v1_tasks_proto_init() {
850 > if File_temporal_server_api_persistence_v1_tasks_proto != nil {
851 return
852 }
853 > type x struct{} tasks.pb.go
854 > out := protoimpl.TypeBuilder{
855 > File: protoimpl.DescBuilder{
856 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
857 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_tasks_proto_rawDesc), len(file_temporal_server_api_persistence_v1_tasks_proto_rawDesc)),
858 > NumEnums: 0,
859 > NumMessages: 8,
860 > NumExtensions: 0,
861 > NumServices: 0,
862 > },
863 > GoTypes: file_temporal_server_api_persistence_v1_tasks_proto_goTypes,
864 > DependencyIndexes: file_temporal_server_api_persistence_v1_tasks_proto_depIdxs,
865 > MessageInfos: file_temporal_server_api_persistence_v1_tasks_proto_msgTypes,
866 > }.Build()
867 > File_temporal_server_api_persistence_v1_tasks_proto = out.File
868 > file_temporal_server_api_persistence_v1_tasks_proto_goTypes = nil
869 > file_temporal_server_api_persistence_v1_tasks_proto_depIdxs = nil
870 }
go.temporal.io/server/api/token/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

785 }
786
787 > func init() { file_temporal_server_api_token_v1_message_proto_init() } message.pb.go
788 > func file_temporal_server_api_token_v1_message_proto_init() {
789 > if File_temporal_server_api_token_v1_message_proto != nil {
790 return
791 }
792 > type x struct{} message.pb.go
793 > out := protoimpl.TypeBuilder{
794 > File: protoimpl.DescBuilder{
795 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
796 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_token_v1_message_proto_rawDesc), len(file_temporal_server_api_token_v1_message_proto_rawDesc)),
797 > NumEnums: 0,
798 > NumMessages: 7,
799 > NumExtensions: 0,
800 > NumServices: 0,
801 > },
802 > GoTypes: file_temporal_server_api_token_v1_message_proto_goTypes,
803 > DependencyIndexes: file_temporal_server_api_token_v1_message_proto_depIdxs,
804 > MessageInfos: file_temporal_server_api_token_v1_message_proto_msgTypes,
805 > }.Build()
806 > File_temporal_server_api_token_v1_message_proto = out.File
807 > file_temporal_server_api_token_v1_message_proto_goTypes = nil
808 > file_temporal_server_api_token_v1_message_proto_depIdxs = nil
809 }
go.temporal.io/server/api/visibilityservice/v1/request_response.pb.go 20 covered LOC · 2 ranges

Open complete file

402 }
403
404 > func init() { file_temporal_server_api_visibilityservice_v1_request_response_proto_init() } request_response.pb.go
405 > func file_temporal_server_api_visibilityservice_v1_request_response_proto_init() {
406 > if File_temporal_server_api_visibilityservice_v1_request_response_proto != nil {
407 return
408 }
409 > type x struct{} request_response.pb.go
410 > out := protoimpl.TypeBuilder{
411 > File: protoimpl.DescBuilder{
412 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
413 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_visibilityservice_v1_request_response_proto_rawDesc), len(file_temporal_server_api_visibilityservice_v1_request_response_proto_rawDesc)),
414 > NumEnums: 0,
415 > NumMessages: 5,
416 > NumExtensions: 0,
417 > NumServices: 0,
418 > },
419 > GoTypes: file_temporal_server_api_visibilityservice_v1_request_response_proto_goTypes,
420 > DependencyIndexes: file_temporal_server_api_visibilityservice_v1_request_response_proto_depIdxs,
421 > MessageInfos: file_temporal_server_api_visibilityservice_v1_request_response_proto_msgTypes,
422 > }.Build()
423 > File_temporal_server_api_visibilityservice_v1_request_response_proto = out.File
424 > file_temporal_server_api_visibilityservice_v1_request_response_proto_goTypes = nil
425 > file_temporal_server_api_visibilityservice_v1_request_response_proto_depIdxs = nil
426 }
go.temporal.io/server/api/workflow/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

278 }
279
280 > func init() { file_temporal_server_api_workflow_v1_message_proto_init() } message.pb.go
281 > func file_temporal_server_api_workflow_v1_message_proto_init() {
282 > if File_temporal_server_api_workflow_v1_message_proto != nil {
283 return
284 }
285 > type x struct{} message.pb.go
286 > out := protoimpl.TypeBuilder{
287 > File: protoimpl.DescBuilder{
288 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
289 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_workflow_v1_message_proto_rawDesc), len(file_temporal_server_api_workflow_v1_message_proto_rawDesc)),
290 > NumEnums: 0,
291 > NumMessages: 3,
292 > NumExtensions: 0,
293 > NumServices: 0,
294 > },
295 > GoTypes: file_temporal_server_api_workflow_v1_message_proto_goTypes,
296 > DependencyIndexes: file_temporal_server_api_workflow_v1_message_proto_depIdxs,
297 > MessageInfos: file_temporal_server_api_workflow_v1_message_proto_msgTypes,
298 > }.Build()
299 > File_temporal_server_api_workflow_v1_message_proto = out.File
300 > file_temporal_server_api_workflow_v1_message_proto_goTypes = nil
301 > file_temporal_server_api_workflow_v1_message_proto_depIdxs = nil
302 }
go.temporal.io/server/chasm/lib/callback/gen/callbackpb/v1/tasks.pb.go 20 covered LOC · 2 ranges

Open complete file

148 }
149
150 > func init() { file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_init() } tasks.pb.go
151 > func file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_init() {
152 > if File_temporal_server_chasm_lib_callback_proto_v1_tasks_proto != nil {
153 return
154 }
155 > type x struct{} tasks.pb.go
156 > out := protoimpl.TypeBuilder{
157 > File: protoimpl.DescBuilder{
158 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
159 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_rawDesc), len(file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_rawDesc)),
160 > NumEnums: 0,
161 > NumMessages: 2,
162 > NumExtensions: 0,
163 > NumServices: 0,
164 > },
165 > GoTypes: file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_goTypes,
166 > DependencyIndexes: file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_depIdxs,
167 > MessageInfos: file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_msgTypes,
168 > }.Build()
169 > File_temporal_server_chasm_lib_callback_proto_v1_tasks_proto = out.File
170 > file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_goTypes = nil
171 > file_temporal_server_chasm_lib_callback_proto_v1_tasks_proto_depIdxs = nil
172 }
go.temporal.io/server/chasm/lib/scheduler/eventlog.go 20 covered LOC · 4 ranges

Open complete file

21 // NewEventLog returns an initialized EventLog component, intended to be parented
22 // under any component that wants to record events.
23 > func NewEventLog(ctx chasm.MutableContext) *EventLog { eventlog.go
24 > return &EventLog{
25 > EventLog: &schedulerpb.EventLog{},
26 > }
27 > }
28
29 func (s *Scheduler) getOrCreateEventLog(ctx chasm.MutableContext) *EventLog {
37 }
38
39 > func (g *Generator) getOrCreateEventLog(ctx chasm.MutableContext) *EventLog { eventlog.go
40 > eventLog, ok := g.EventLog.TryGet(ctx)
41 > if ok {
42 > return eventLog
43 > }
44 eventLog = NewEventLog(ctx)
45 g.EventLog = chasm.NewComponentField(ctx, eventLog)
74 // configured maximum length are truncated at a UTF-8 rune boundary; once the
75 // log exceeds the configured maximum entries, the earliest entries are dropped.
76 > func (e *EventLog) LogEvent(ctx chasm.MutableContext, msg string) { eventlog.go
77 > tw := tweakablesFromContext(ctx)
78 > maxEntries, maxMessageLen := tw.EventLogMaxEntries, tw.EventLogMaxMessageLen
79 >
80 > if len(msg) > maxMessageLen {
81 // Back off to the nearest UTF-8 rune boundary so we don't split a
82 // multibyte rune.
87 msg = msg[:truncateAt]
88 }
89 > e.Events = append(e.Events, &schedulerpb.Event{ eventlog.go
90 > Time: timestamppb.New(ctx.Now(e)),
91 > Message: msg,
92 > })
93 > if keepFrom := len(e.Events) - maxEntries; keepFrom > 0 {
94 // Clone so the dropped entries don't stay reachable via the backing array.
95 e.Events = slices.Clone(e.Events[keepFrom:])
go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/service.pb.go 20 covered LOC · 2 ranges

Open complete file

86 }
87
88 > func init() { file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_init() } service.pb.go
89 > func file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_init() {
90 > if File_temporal_server_chasm_lib_scheduler_proto_v1_service_proto != nil {
91 return
92 }
93 > file_temporal_server_chasm_lib_scheduler_proto_v1_request_response_proto_init() service.pb.go
94 > type x struct{}
95 > out := protoimpl.TypeBuilder{
96 > File: protoimpl.DescBuilder{
97 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
98 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_rawDesc), len(file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_rawDesc)),
99 > NumEnums: 0,
100 > NumMessages: 0,
101 > NumExtensions: 0,
102 > NumServices: 1,
103 > },
104 > GoTypes: file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_goTypes,
105 > DependencyIndexes: file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_depIdxs,
106 > }.Build()
107 > File_temporal_server_chasm_lib_scheduler_proto_v1_service_proto = out.File
108 > file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_goTypes = nil
109 > file_temporal_server_chasm_lib_scheduler_proto_v1_service_proto_depIdxs = nil
110 }
go.temporal.io/server/chasm/lib/scheduler/invoker.go 20 covered LOC · 6 ranges

Open complete file

33 // NewInvoker returns an initialized Invoker component, which should
34 // be parented under a Scheduler root component.
35 > func NewInvoker(ctx chasm.MutableContext) *Invoker { invoker.go
36 > return newInvokerWithState(ctx, &schedulerpb.InvokerState{
37 > BufferedStarts: []*schedulespb.BufferedStart{},
38 > })
39 > }
40
41 > func newInvokerWithState(ctx chasm.MutableContext, state *schedulerpb.InvokerState) *Invoker { invoker.go
42 > i := &Invoker{
43 > InvokerState: state,
44 > EventLog: chasm.NewComponentField(ctx, NewEventLog(ctx)),
45 > }
46 > return i
47 > }
48
49 // EnqueueBufferedStarts adds new BufferedStarts to the invocation queue,
378 // runningWorkflowExecutions returns the list of workflow executions that
379 // have been started but not yet completed.
380 > func (i *Invoker) runningWorkflowExecutions() []*commonpb.WorkflowExecution { invoker.go
381 > var running []*commonpb.WorkflowExecution
382 > for _, start := range i.GetBufferedStarts() {
383 if start.GetRunId() != "" && start.GetCompleted() == nil {
384 running = append(running, &commonpb.WorkflowExecution{
388 }
389 }
390 > return running invoker.go
391 }
392
394 // This includes both running workflows (with status RUNNING) and completed
395 // workflows (with their final status).
396 > func (i *Invoker) recentActions() []*schedulepb.ScheduleActionResult { invoker.go
397 > var results []*schedulepb.ScheduleActionResult
398 > for _, start := range i.GetBufferedStarts() {
399 // Only include workflows that have been started (have a RunId).
400 if start.GetRunId() == "" {
415 })
416 }
417 > return results invoker.go
418 }
419
go.temporal.io/server/common/util/wildcard.go 20 covered LOC · 7 ranges

Open complete file

18 // WildCardStringToRegexps converts a given slices of string patterns to a slice of regular expressions matching
19 // wildcards (*) with any substring.
20 > func WildCardStringsToRegexp(patterns []string) (*regexp.Regexp, error) { wildcard.go
21 > var result strings.Builder
22 > result.WriteRune('^')
23 > for i, pattern := range patterns {
24 > result.WriteRune('(')
25 > first := true
26 > for literal := range strings.SplitSeq(pattern, "*") {
27 > if !first {
28 // Replace * with .*
29 result.WriteString(".*")
30 }
31 > result.WriteString(regexp.QuoteMeta(literal)) wildcard.go
32 > first = false
33 }
34 > result.WriteRune(')') wildcard.go
35 > if i < len(patterns)-1 {
36 > result.WriteRune('|') wildcard.go
37 > }
38 }
39 > result.WriteRune('$') wildcard.go
40 > return regexp.Compile(result.String())
41 }
42
43 // MustWildCardStringsToRegexp is like WildCardStringsToRegexp but panics on error.
44 > func MustWildCardStringsToRegexp(patterns []string) *regexp.Regexp { wildcard.go
45 > re, err := WildCardStringsToRegexp(patterns)
46 > if err != nil {
47 panic(err) //nolint:forbidigo // Must* functions conventionally panic on error.
48 }
49 > return re wildcard.go
50 }
go.temporal.io/server/common/testing/testvars/any.go 19 covered LOC · 5 ranges

Open complete file

18 }
19
20 > func newAny(testName string, testHash uint32) Any { any.go
21 > return Any{
22 > testName: testName,
23 > testHash: testHash,
24 > }
25 > }
26
27 > func (a Any) String() string { any.go
28 > return a.testName + "_any_random_string_" + randString(5)
29 > }
30
31 func (a Any) Payload() *commonpb.Payload {
37 }
38
39 > func (a Any) Int() int { any.go
40 > // This produces number in XXX000YYY format, where XXX is unique for every test and YYY is a random number.
41 > return randInt(a.testHash, 3, 3, 3)
42 > }
43
44 func (a Any) Int32() int32 {
77 }
78
79 > func (a Any) RunID() string { any.go
80 > return uuid.NewString()
81 > }
82
83 > func (a Any) WorkflowKey() definition.WorkflowKey { any.go
84 > return definition.NewWorkflowKey(a.String(), a.String(), a.RunID())
85 > }
go.temporal.io/server/chasm/lib/scheduler/invoker_tasks.go 18 covered LOC · 2 ranges

Open complete file

101 )
102
103 > func NewInvokerExecuteTaskHandler(opts InvokerTaskHandlerOptions) *InvokerExecuteTaskHandler { invoker_tasks.go
104 > return &InvokerExecuteTaskHandler{
105 > config: opts.Config,
106 > metricsHandler: opts.MetricsHandler,
107 > baseLogger: opts.BaseLogger,
108 > historyClient: opts.HistoryClient,
109 > frontendClient: opts.FrontendClient,
110 > }
111 > }
112
113 > func NewInvokerProcessBufferTaskHandler(opts InvokerTaskHandlerOptions) *InvokerProcessBufferTaskHandler { invoker_tasks.go
114 > return &InvokerProcessBufferTaskHandler{
115 > config: opts.Config,
116 > metricsHandler: opts.MetricsHandler,
117 > baseLogger: opts.BaseLogger,
118 > historyClient: opts.HistoryClient,
119 > frontendClient: opts.FrontendClient,
120 > }
121 > }
122
123 // recordDuplicateExecuteDrops emits a metric + Debug log for CompletedStarts
go.temporal.io/server/common/dynamicconfig/collection.go 18 covered LOC · 3 ranges

Open complete file

676 // treat the fields independently), or the zero value of its type (if you want to treat the fields
677 // as a group and default unset fields to zero).
678 > func ConvertStructure[T any](def T) func(v any) (T, error) { collection.go
679 > return func(v any) (T, error) {
680 > // if we already have the right type, no conversion is necessary
681 > if typedV, ok := v.(T); ok {
682 return typedV, nil
683 }
685 // Deep-copy the default and decode over it. This allows using e.g. a struct with some
686 // default fields filled in and a config that only set some fields.
687 > out := deepCopyForMapstructure(def) collection.go
688 >
689 > dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
690 > Result: &out,
691 > DecodeHook: mapstructure.ComposeDecodeHookFunc(
692 > mapstructureHookDuration,
693 > mapstructureHookTimestamp,
694 > mapstructureHookProtoEnum,
695 > mapstructureHookGeneric,
696 > ),
697 > })
698 > if err != nil {
699 return out, err
700 }
701 > err = dec.Decode(v) collection.go
702 > return out, err
703 }
704 }
go.temporal.io/server/chasm/library_core.go 16 covered LOC · 3 ranges

Open complete file

6 }
7
8 > func (b *CoreLibrary) Name() string { library_core.go
9 > return "core"
10 > }
11
12 > func (b *CoreLibrary) Components() []*RegistrableComponent { library_core.go
13 > return []*RegistrableComponent{
14 > NewRegistrableComponent[*Visibility]("vis", WithDetached()),
15 > }
16 > }
17
18 > func (b *CoreLibrary) Tasks() []*RegistrableTask { library_core.go
19 > return []*RegistrableTask{
20 > NewRegistrableSideEffectTask(
21 > "visTask",
22 > defaultVisibilityTaskHandler,
23 > ),
24 > }
25 > }
go.temporal.io/server/chasm/parent_pointer.go 16 covered LOC · 10 ranges

Open complete file

35 // Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the
36 // application.
37 > func (p ParentPtr[T]) Get(chasmContext Context) T { parent_pointer.go
38 > vT, ok := p.TryGet(chasmContext)
39 > if !ok {
40 // nolint:forbidigo // Panic is intended here for framework error handling.
41 panic(serviceerror.NewInternal("expect parent component value but got nil"))
42 }
43 > return vT parent_pointer.go
44 }
45
48 // Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the
49 // application.
50 > func (p ParentPtr[T]) TryGet(chasmContext Context) (T, bool) { parent_pointer.go
51 > var nilT T
52 > if p.Internal.currentNode == nil {
53 // ParentPtr not initialized
54 return nilT, false
55 }
56
57 > parent := p.Internal.currentNode.parent parent_pointer.go
58 > if parent == nil {
59 return nilT, false
60 }
61
62 > for parent.isMap() { parent_pointer.go
63 parent = parent.parent
64 if parent == nil {
73 }
74
75 > if !parent.isComponent() { parent_pointer.go
76 // nolint:forbidigo // Panic is intended here for framework error handling.
77 panic(softassert.UnexpectedInternalErr(
85 }
86
87 > if err := parent.prepareComponentValue(chasmContext); err != nil { parent_pointer.go
88 // nolint:forbidigo // Panic is intended here for framework error handling.
89 panic(err)
90 }
91
92 > if parent.value == nil { parent_pointer.go
93 return nilT, false
94 }
95
96 > vT, isT := parent.value.(T) parent_pointer.go
97 > if !isT {
98 // nolint:forbidigo // Panic is intended here for framework error handling.
99 panic(serviceerror.NewInternalf("parent component value doesn't implement %s", reflect.TypeFor[T]().Name()))
100 }
101 > return vT, true parent_pointer.go
102 }
go.temporal.io/server/common/metrics/noop_impl.go 16 covered LOC · 8 ranges

Open complete file

15 )
16
17 > func newNoopMetricsHandler() *noopMetricsHandler { return &noopMetricsHandler{} } noop_impl.go
18
19 // WithTags creates a new MetricProvder with provided []Tag
20 // Tags are merged with registered Tags from the source MetricsHandler
21 > func (n *noopMetricsHandler) WithTags(...Tag) Handler { noop_impl.go
22 > return n
23 > }
24
25 // Counter obtains a counter for the given name.
26 > func (*noopMetricsHandler) Counter(string) CounterIface { noop_impl.go
27 > return NoopCounterMetricFunc
28 > }
29
30 // Gauge obtains a gauge for the given name.
31 > func (*noopMetricsHandler) Gauge(string) GaugeIface { noop_impl.go
32 > return NoopGaugeMetricFunc
33 > }
34
35 // Timer obtains a timer for the given name.
36 > func (*noopMetricsHandler) Timer(string) TimerIface { noop_impl.go
37 > return NoopTimerMetricFunc
38 > }
39
40 // Histogram obtains a histogram for the given name.
53 }
54
55 > var NoopCounterMetricFunc = CounterFunc(func(i int64, t ...Tag) {}) noop_impl.go
56 > var NoopGaugeMetricFunc = GaugeFunc(func(f float64, t ...Tag) {}) noop_impl.go
57 > var NoopTimerMetricFunc = TimerFunc(func(d time.Duration, t ...Tag) {}) noop_impl.go
58 var NoopHistogramMetricFunc = HistogramFunc(func(i int64, t ...Tag) {})
go.temporal.io/server/chasm/component.go 15 covered LOC · 6 ranges

Open complete file

78 )
79
80 > func (s LifecycleState) IsClosed() bool { component.go
81 > return s >= LifecycleStateCompleted
82 > }
83
84 > func (s LifecycleState) IsPaused() bool { component.go
85 > return s == LifecycleStatePaused
86 > }
87
88 func (s LifecycleState) String() string {
122 ctx context.Context,
123 intent OperationIntent,
124 > ) context.Context { component.go
125 > return context.WithValue(ctx, operationIntentCtxKey, intent)
126 > }
127
128 func operationIntentFromContext(
129 ctx context.Context,
130 > ) OperationIntent { component.go
131 > intent, ok := ctx.Value(operationIntentCtxKey).(OperationIntent)
132 > if !ok {
133 > return OperationIntentUnspecified component.go
134 > }
135 > return intent component.go
136 }
go.temporal.io/server/common/namespace/replication_resolver.go 15 covered LOC · 2 ranges

Open complete file

49 }
50
51 > func NewDefaultReplicationResolverFactory() ReplicationResolverFactory { replication_resolver.go
52 > return func(detail *persistencespb.NamespaceDetail) ReplicationResolver {
53 > // By convention, a namespace with non-zero failover version is a global namespace
54 > // This can be overridden by WithGlobalFlag mutation if needed
55 > isGlobal := detail.FailoverVersion != 0
56 > return &defaultReplicationResolver{
57 > replicationConfig: detail.ReplicationConfig,
58 > isGlobalNamespace: isGlobal,
59 > failoverVersion: detail.FailoverVersion,
60 > failoverNotificationVersion: detail.FailoverNotificationVersion,
61 > }
62 > }
63 }
64
112 }
113
114 > func (r *defaultReplicationResolver) SetGlobalFlag(isGlobal bool) { replication_resolver.go
115 > r.isGlobalNamespace = isGlobal
116 > }
117
118 func (r *defaultReplicationResolver) SetActiveCluster(clusterName string) {
go.temporal.io/server/common/persistence/visibility/store/sql/query_converter_util_legacy.go 15 covered LOC · 3 ranges

Open complete file

68 }
69
70 > func newColName(name string) *colName { query_converter_util_legacy.go
71 > return &colName{Name: name}
72 > }
73
74 func newSAColName(
77 fieldName string,
78 valueType enumspb.IndexedValueType,
79 > ) *saColName { query_converter_util_legacy.go
80 > return &saColName{
81 > dbColName: newColName(dbColName),
82 > alias: alias,
83 > fieldName: fieldName,
84 > valueType: valueType,
85 > }
86 > }
87
88 func newFuncExpr(name string, exprs ...sqlparser.Expr) *sqlparser.FuncExpr {
105 }
106
107 > func getMaxDatetimeValue() time.Time { query_converter_util_legacy.go
108 > t, _ := time.Parse(time.RFC3339, "9999-12-31T23:59:59Z")
109 > return t
110 > }
111
112 // formatComparisonExprStringForError formats comparison expression after
go.temporal.io/server/chasm/lib/scheduler/scheduler_tasks.go 14 covered LOC · 2 ranges

Open complete file

41 }
42
43 > func NewSchedulerIdleTaskHandler(opts SchedulerIdleTaskHandlerOptions) *SchedulerIdleTaskHandler { scheduler_tasks.go
44 > return &SchedulerIdleTaskHandler{
45 > config: opts.Config,
46 > metricsHandler: opts.MetricsHandler,
47 > baseLogger: opts.BaseLogger,
48 > }
49 > }
50
51 func (r *SchedulerIdleTaskHandler) Execute(
134 }
135
136 > func NewSchedulerCallbacksTaskHandler(opts SchedulerCallbacksTaskHandlerOptions) *SchedulerCallbacksTaskHandler { scheduler_tasks.go
137 > return &SchedulerCallbacksTaskHandler{
138 > config: opts.Config,
139 > historyClient: opts.HistoryClient,
140 > frontendClient: opts.FrontendClient,
141 > }
142 > }
143
144 // watchResult holds the outcome of watchRunningStart for a single BufferedStart.
go.temporal.io/server/common/build/build.go 14 covered LOC · 2 ranges

Open complete file

27 )
28
29 > func init() { build.go
30 > buildInfo, ok := debug.ReadBuildInfo()
31 > if !ok {
32 return
33 }
34
35 > InfoData.Available = true build.go
36 > InfoData.GoVersion = buildInfo.GoVersion
37 >
38 > for _, setting := range buildInfo.Settings {
39 > switch setting.Key {
40 > case "GOARCH":
41 > InfoData.GoArch = setting.Value
42 > case "GOOS":
43 > InfoData.GoOs = setting.Value
44 > case "CGO_ENABLED":
45 > InfoData.CgoEnabled = setting.Value == "1"
46 case "vcs.revision":
47 InfoData.GitRevision = setting.Value
go.temporal.io/server/common/dynamicconfig/gradual_change.go 14 covered LOC · 3 ranges

Open complete file

25 // StaticGradualChange returns a GradualChange whose Value always returns def and whose When
26 // always returns a time in the past.
27 > func StaticGradualChange[T any](def T) GradualChange[T] { gradual_change.go
28 > return GradualChange[T]{New: def}
29 > }
30
31 // Value returns the value for the given key at the given time.
56 // of type GradualChange into a GradualChange.
57 // nolint:revive // cognitive-complexity // this looks complicated but each case is fairly simple
58 > func ConvertGradualChange[T any](def T) func(v any) (GradualChange[T], error) { gradual_change.go
59 > changeConverter := ConvertStructure(StaticGradualChange(def))
60 >
61 > // Call this once so that if it's going to panic, it panics at static init time.
62 > _, _ = changeConverter(nil)
63 >
64 > switch reflect.TypeFor[T]() {
65 > case reflect.TypeFor[bool]():
66 > return func(v any) (GradualChange[T], error) {
67 if b, err := convertBool(v); err == nil {
68 var change GradualChange[T]
72 return changeConverter(v)
73 }
74 > case reflect.TypeFor[int](): gradual_change.go
75 > return func(v any) (GradualChange[T], error) {
76 if i, err := convertInt(v); err == nil {
77 var change GradualChange[T]
go.temporal.io/server/common/metrics/tags.go 14 covered LOC · 8 ranges

Open complete file

101 // dual emit the metric with the all tag. If a blank namespace is provided then
102 // this converts that to an unknown namespace.
103 > func NamespaceTag(value string) Tag { tags.go
104 > if len(value) == 0 {
105 value = unknownValue
106 }
107 > return Tag{Key: namespace, Value: value} tags.go
108 }
109
286 }
287
288 > func ArchetypeTag(value string) Tag { tags.go
289 > if len(value) == 0 {
290 > value = unknownValue tags.go
291 > }
292 > return Tag{Key: ArchetypeTagName, Value: value} tags.go
293 }
294
295 > func ChasmTaskTypeTag(value string) Tag { tags.go
296 > if len(value) == 0 {
297 value = unknownValue
298 }
299 > return Tag{Key: ChasmTaskTypeTagName, Value: value} tags.go
300 }
301
459 }
460
461 > func StringTag(key string, value string) Tag { tags.go
462 > return Tag{Key: key, Value: value}
463 > }
464
465 func CacheTypeTag(value string) Tag {
go.temporal.io/server/common/primitives/timestamp/duration.go 14 covered LOC · 6 ranges

Open complete file

19 )
20
21 > func DurationValue(d *durationpb.Duration) time.Duration { duration.go
22 > if d == nil {
23 > return 0 duration.go
24 > }
25 > return d.AsDuration() duration.go
26 }
27
28 > func DurationPtr(td time.Duration) *durationpb.Duration { duration.go
29 > return durationpb.New(td)
30 > }
31
32 func MinDurationPtr(d1 *durationpb.Duration, d2 *durationpb.Duration) *durationpb.Duration {
47 }
48
49 > func DurationFromDays(d int32) *durationpb.Duration { duration.go
50 > return durationMultipleOf(int64(d), time.Hour*24)
51 > }
52
53 > func durationMultipleOf(amt int64, mult time.Duration) *durationpb.Duration { duration.go
54 > return DurationPtr(time.Duration(amt) * mult)
55 > }
56
57 // ValidateAndCapProtoDuration validates protobuf durations for two conditions:
go.temporal.io/server/common/dynamicconfig/shared_structure.go 13 covered LOC · 5 ranges

Open complete file

17 )
18
19 > func warnDefaultSharedStructure(key string, def any) { shared_structure.go
20 > if path := hasSharedStructure(reflect.ValueOf(def), "root"); path != "" {
21 sharedStructureWarnings.Store(key, path)
22 }
42 }
43
44 > func hasSharedStructure(v reflect.Value, path string) string { shared_structure.go
45 > // nolint:exhaustive // deliberately not exhaustive
46 > switch v.Kind() {
47 > case reflect.Map, reflect.Slice, reflect.Pointer:
48 > if !v.IsNil() {
49 return path
50 }
51 > case reflect.Interface: shared_structure.go
52 > if !v.IsNil() {
53 return hasSharedStructure(v.Elem(), path)
54 }
55 > case reflect.Struct: shared_structure.go
56 > for i := range v.NumField() {
57 > if p := hasSharedStructure(v.Field(i), path+"."+v.Type().Field(i).Name); p != "" {
58 return p
59 }
go.temporal.io/server/common/metrics/defs_base.go 13 covered LOC · 2 ranges

Open complete file

10 }
11
12 > func newMetricDefinition(name string, opts ...Option) metricDefinition { defs_base.go
13 > d := metricDefinition{
14 > name: name,
15 > description: "",
16 > unit: "",
17 > }
18 > for _, opt := range opts {
19 > opt.apply(&d)
20 > }
21 > return d
22 }
23
24 > func (md metricDefinition) Name() string { defs_base.go
25 > return md.name
26 > }
27
28 func (md metricDefinition) Unit() MetricUnit {
go.temporal.io/server/common/testing/testvars/rand.go 13 covered LOC · 2 ranges

Open complete file

6 )
7
8 > func randInt(testHash uint32, hashLen, padLen, randomLen int) int { rand.go
9 > testID := int(testHash) % int(math.Pow10(hashLen))
10 > pad := int(math.Pow10(padLen + randomLen))
11 > random := rand.Int() % int(math.Pow10(randomLen))
12 > return testID*pad + random
13 > }
14
15 > func randString(n int) string { rand.go
16 > const letterBytes = "abcdefghijklmnopqrstuvwxyz"
17 > b := make([]byte, n)
18 > for i := range b {
19 > b[i] = letterBytes[rand.Intn(len(letterBytes))]
20 > }
21 > return string(b)
22 }
go.temporal.io/server/common/persistence/visibility/store/elasticsearch/visibility_store.go 12 covered LOC · 3 ranges

Open complete file

101 }
102
103 > defaultSorter = func() []elastic.Sorter { visibility_store.go
104 > ret := make([]elastic.Sorter, 0, len(defaultSorterFields))
105 > for _, item := range defaultSorterFields {
106 > fs := elastic.NewFieldSort(item.name)
107 > if item.desc {
108 > fs.Desc()
109 > }
110 > if item.missing_first {
111 > fs.Missing("_first")
112 > } else {
113 fs.Missing("_last")
114 }
115 > ret = append(ret, fs) visibility_store.go
116 }
117 > return ret visibility_store.go
118 }()
119
go.temporal.io/server/common/util/util.go 12 covered LOC · 5 ranges

Open complete file

20
21 // MaxTime returns the latest of the given time.Time values.
22 > func MaxTime(first time.Time, rest ...time.Time) time.Time { util.go
23 > latest := first
24 > for _, t := range rest {
25 > if t.After(latest) {
26 latest = t
27 }
28 }
29 > return latest util.go
30 }
31
43
44 // SliceHead returns the first n elements of s. n may be greater than len(s).
45 > func SliceHead[S ~[]E, E any](s S, n int) S { util.go
46 > if n < len(s) {
47 return s[:n]
48 }
49 > return s util.go
50 }
51
68
69 // InverseMap creates the inverse map, ie., for a key-value map, it builds the value-key map.
70 > func InverseMap[M ~map[K]V, K, V comparable](m M) map[V]K { util.go
71 > if m == nil {
72 > return nil
73 > }
74 invm := make(map[V]K, len(m))
75 for k, v := range m {
go.temporal.io/server/chasm/lib/scheduler/config.go 10 covered LOC · 5 ranges

Open complete file

40 // tweakablesFromContext returns the scheduler Tweakables for the context's namespace,
41 // falling back to DefaultTweakables when no config is registered.
42 > func tweakablesFromContext(ctx chasm.Context) Tweakables { config.go
43 > if fn, ok := ctx.Value(tweakablesCtxKey).(dynamicconfig.TypedPropertyFnWithNamespaceFilter[Tweakables]); ok && fn != nil {
44 > return fn(ctx.NamespaceEntry().Name().String()) config.go
45 > }
46 return DefaultTweakables
47 }
48
49 // contextValues builds the CHASM context values exposed to scheduler components.
50 > func (c *Config) contextValues() map[any]any { config.go
51 > var tweakables dynamicconfig.TypedPropertyFnWithNamespaceFilter[Tweakables]
52 > if c != nil {
53 > tweakables = c.Tweakables config.go
54 > }
55 > return map[any]any{tweakablesCtxKey: tweakables} config.go
56 }
57
go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/plugin.go 10 covered LOC · 1 range

Open complete file

36 var _ sqlplugin.Plugin = (*plugin)(nil)
37
38 > func init() { plugin.go
39 > sql.RegisterPlugin(PluginName, &plugin{
40 > driver: &driver.PQDriver{},
41 > queryConverter: &queryConverter{},
42 > })
43 > sql.RegisterPlugin(PluginNamePGX, &plugin{
44 > driver: &driver.PGXDriver{},
45 > queryConverter: &queryConverter{},
46 > })
47 > }
48
49 func (p *plugin) GetVisibilityQueryConverter() sqlplugin.VisibilityQueryConverter {
go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/visibility.go 10 covered LOC · 1 range

Open complete file

40 )
41
42 > func buildOnDuplicateKeyUpdate(fields ...string) string { visibility.go
43 > items := make([]string, len(fields))
44 > for i, field := range fields {
45 > items[i] = fmt.Sprintf("%s = excluded.%s", field, field)
46 > }
47 > return fmt.Sprintf(
48 > // The WHERE clause ensures that no update occurs if the version is behind the saved version.
49 > "ON CONFLICT (namespace_id, run_id) DO UPDATE SET %s WHERE executions_visibility.%s < EXCLUDED.%s",
50 > strings.Join(items, ", "), sqlplugin.VersionColumnName, sqlplugin.VersionColumnName,
51 > )
52 }
53
go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite/visibility.go 10 covered LOC · 1 range

Open complete file

42 )
43
44 > func buildOnDuplicateKeyUpdate(fields ...string) string { visibility.go
45 > items := make([]string, len(fields))
46 > for i, field := range fields {
47 > items[i] = fmt.Sprintf("%s = excluded.%s", field, field)
48 > }
49 > return fmt.Sprintf(
50 > // The WHERE clause ensures that no update occurs if the version is behind the saved version.
51 > "ON CONFLICT (namespace_id, run_id) DO UPDATE SET %s WHERE executions_visibility.%s < EXCLUDED.%s",
52 > strings.Join(items, ", "), sqlplugin.VersionColumnName, sqlplugin.VersionColumnName,
53 > )
54 }
55
go.temporal.io/server/common/persistence/sql/sqlplugin/visibility.go 10 covered LOC · 2 ranges

Open complete file

219 }
220
221 > func getDbFields() []string { visibility.go
222 > t := reflect.TypeFor[VisibilityRow]()
223 > dbFields := make([]string, t.NumField())
224 > for i := 0; i < t.NumField(); i++ {
225 > f := t.Field(i)
226 > dbFields[i] = f.Tag.Get("db")
227 > if dbFields[i] == "" {
228 > dbFields[i] = strcase.ToSnake(f.Name)
229 > }
230 }
231 > return dbFields visibility.go
232 }
233
go.temporal.io/server/common/persistence/visibility/store/query/util.go 10 covered LOC · 2 ranges

Open complete file

70 }
71
72 > func NewUnsafeSQLString(val string) *UnsafeSQLString { util.go
73 > return &UnsafeSQLString{Val: val}
74 > }
75
76 func NewColName(name string) *ColumnName {
78 }
79
80 > func NewSAColumn(alias string, fieldName string, valueType enumspb.IndexedValueType) *SAColumn { util.go
81 > return &SAColumn{
82 > Alias: alias,
83 > FieldName: fieldName,
84 > ValueType: valueType,
85 > }
86 > }
87
88 func NamespaceDivisionSAColumn() *SAColumn {
go.temporal.io/server/chasm/lib/scheduler/scheduler_migrate_task.go 9 covered LOC · 1 range

Open complete file

54 func NewSchedulerMigrateToWorkflowTaskHandler(
55 opts SchedulerMigrateToWorkflowTaskHandlerOptions,
56 > ) *SchedulerMigrateToWorkflowTaskHandler { scheduler_migrate_task.go
57 > return &SchedulerMigrateToWorkflowTaskHandler{
58 > config: opts.Config,
59 > metricsHandler: opts.MetricsHandler,
60 > baseLogger: opts.BaseLogger,
61 > historyClient: opts.HistoryClient,
62 > saMapperProvider: opts.SaMapperProvider,
63 > }
64 > }
65
66 func (h *SchedulerMigrateToWorkflowTaskHandler) Validate(
go.temporal.io/server/chasm/library.go 9 covered LOC · 3 ranges

Open complete file

42 }
43
44 > func (UnimplementedLibrary) NexusServices() []*nexus.Service { library.go
45 > return nil
46 > }
47
48 > func (UnimplementedLibrary) NexusServiceProcessors() []*NexusServiceProcessor { library.go
49 > return nil
50 > }
51
52 func (UnimplementedLibrary) mustEmbedUnimplementedLibrary() {}
56 // tasks within the CHASM framework.
57 // The format of the returned FQN is: "libName.name"
58 > func FullyQualifiedName(libName, name string) string { library.go
59 > return libName + "." + name
60 > }
go.temporal.io/server/common/persistence/sql/sqlplugin/util.go 9 covered LOC · 2 ranges

Open complete file

5 )
6
7 > func appendPrefix(prefix string, fields []string) []string { util.go
8 > out := make([]string, len(fields))
9 > for i, field := range fields {
10 > out[i] = prefix + field
11 > }
12 > return out
13 }
14
15 > func BuildNamedPlaceholder(fields ...string) string { util.go
16 > return strings.Join(appendPrefix(":", fields), ", ")
17 > }
go.temporal.io/server/common/testing/testhooks/test_impl.go 9 covered LOC · 2 ranges

Open complete file

89 var keyCounter atomic.Int64
90
91 > func newKey[T any, S any]() Key[T, S] { test_impl.go
92 > var zero S
93 > var s ScopeType
94 > switch any(zero).(type) {
95 > case namespace.ID, namespace.Name:
96 > s = ScopeNamespace
97 > case global:
98 > s = ScopeGlobal
99 default:
100 panic("testhooks: unknown scope type")
101 }
102 > return Key[T, S]{id: keyCounter.Add(1), scopeType: s} test_impl.go
103 }
go.temporal.io/server/chasm/lib/scheduler/backfiller_tasks.go 8 covered LOC · 1 range

Open complete file

36 )
37
38 > func NewBackfillerTaskHandler(opts BackfillerTaskHandlerOptions) *BackfillerTaskHandler { backfiller_tasks.go
39 > return &BackfillerTaskHandler{
40 > config: opts.Config,
41 > metricsHandler: opts.MetricsHandler,
42 > baseLogger: opts.BaseLogger,
43 > specProcessor: opts.SpecProcessor,
44 > }
45 > }
46
47 // BackfillerTask invalidation reasons. Limited cardinality for ReasonTag.
go.temporal.io/server/common/namespace/mutate.go 8 covered LOC · 2 ranges

Open complete file

8 type mutationFunc func(*Namespace)
9
10 > func (f mutationFunc) apply(ns *Namespace) { mutate.go
11 > f(ns)
12 > }
13
14 // WithActiveCluster assigns the active cluster to a Namespace during a Clone
43
44 // WithGlobalFlag sets whether or not this Namespace is global.
45 > func WithGlobalFlag(b bool) Mutation { mutate.go
46 > return mutationFunc(
47 > func(ns *Namespace) {
48 > ns.replicationResolver.SetGlobalFlag(b)
49 > })
50 }
51
go.temporal.io/server/common/persistence/sql/sqlplugin/mysql/visibility.go 8 covered LOC · 1 range

Open complete file

73 )
74
75 > func buildOnDuplicateKeyUpdate(fields ...string) string { visibility.go
76 > items := make([]string, len(fields))
77 > for i, field := range fields {
78 > // This line is to ensure that no update occurs (for any column) if the version is behind the saved version.
79 > items[i] = fmt.Sprintf("%v = IF(%v < VALUES(%v), VALUES(%v), %v)",
80 > field, sqlplugin.VersionColumnName, sqlplugin.VersionColumnName, field, field)
81 > }
82 > return fmt.Sprintf("ON DUPLICATE KEY UPDATE %s", strings.Join(items, ", "))
83 }
84
go.temporal.io/server/chasm/statemachine.go 7 covered LOC · 1 range

Open complete file

34 // The apply function is called after verifying the transition is possible but before setting the destination state,
35 // so it can inspect the current (source) state.
36 > func NewTransition[S comparable, SM StateMachine[S], E any](src []S, dst S, apply func(SM, MutableContext, E) error) Transition[S, SM, E] { statemachine.go
37 > return Transition[S, SM, E]{
38 > Sources: src,
39 > Destination: dst,
40 > apply: apply,
41 > }
42 > }
43
44 // Possible returns a boolean indicating whether the transition is possible for the current state.
go.temporal.io/server/chasm/task.go 7 covered LOC · 2 ranges

Open complete file

91
92 // IsImmediate reports whether the task is scheduled for immediate execution (zero or unset scheduled time).
93 > func (a *TaskAttributes) IsImmediate() bool { task.go
94 > return a.ScheduledTime.IsZero() ||
95 > a.ScheduledTime.Equal(TaskScheduledTimeImmediate)
96 > }
97
98 // IsValid reports whether the task attributes are well-formed. A Destination may only be set on
99 // immediate tasks; deferred tasks with a Destination are invalid.
100 > func (a *TaskAttributes) IsValid() bool { task.go
101 > return a.Destination == "" || a.IsImmediate()
102 > }
go.temporal.io/server/common/definition/workflow_key.go 7 covered LOC · 1 range

Open complete file

19 workflowID string,
20 runID string,
21 > ) WorkflowKey { workflow_key.go
22 > return WorkflowKey{
23 > NamespaceID: namespaceID,
24 > WorkflowID: workflowID,
25 > RunID: runID,
26 > }
27 > }
28
29 func (k *WorkflowKey) GetNamespaceID() string {
go.temporal.io/server/common/dynamicconfig/registry.go 7 covered LOC · 3 ranges

Open complete file

17 )
18
19 > func register(s GenericSetting) { registry.go
20 > if globalRegistry.queried.Load() {
21 panic("dynamicconfig.New*Setting must only be called from static initializers")
22 }
23 > if globalRegistry.settings == nil { registry.go
24 > globalRegistry.settings = make(map[Key]GenericSetting)
25 > }
26 > if globalRegistry.settings[s.Key()] != nil {
27 // nolint:forbidigo // only called during static initialization
28 panic(fmt.Sprintf("duplicate registration of dynamic config key: %q", s.Key().String()))
29 }
30 > globalRegistry.settings[s.Key()] = s registry.go
31 }
32
go.temporal.io/server/common/membership/grpc_resolver.go 7 covered LOC · 2 ranges

Open complete file

53 )
54
55 > func init() { grpc_resolver.go
56 > // This must be called in init to avoid race conditions.
57 > resolver.Register(&globalGrpcBuilder)
58 > }
59
60 // Most code should not use this, this is only exposed for code that has to recognize and use a
80 }
81
82 > func (m *grpcBuilder) Scheme() string { grpc_resolver.go
83 > return grpcResolverScheme
84 > }
85
86 func (m *grpcBuilder) getServiceResolver(u *url.URL) (ServiceResolver, error) {
go.temporal.io/server/common/util.go 7 covered LOC · 2 ranges

Open complete file

161
162 // CreatePersistenceClientRetryPolicy creates a retry policy for calls to persistence
163 > func CreatePersistenceClientRetryPolicy() backoff.RetryPolicy { util.go
164 > return backoff.NewExponentialRetryPolicy(persistenceClientRetryInitialInterval).
165 > WithMaximumAttempts(persistenceClientRetryMaxAttempts)
166 > }
167
168 // CreateFrontendClientRetryPolicy creates a retry policy for calls to frontend service
688
689 // CloneProto is a generic typed version of proto.Clone from proto.
690 > func CloneProto[T proto.Message](v T) T { util.go
691 > return proto.Clone(v).(T)
692 > }
693
694 func CloneProtoMap[K comparable, T proto.Message](src map[K]T) map[K]T {
go.temporal.io/server/common/clock/time_source.go 6 covered LOC · 2 ranges

Open complete file

31
32 // NewRealTimeSource returns a timeSource that uses the real wall timeSource time.
33 > func NewRealTimeSource() RealTimeSource { time_source.go
34 > return RealTimeSource{}
35 > }
36
37 // Now returns the current time, with the location set to UTC.
38 > func (ts RealTimeSource) Now() time.Time { time_source.go
39 > return time.Now().UTC()
40 > }
41
42 // Since returns the time elapsed since t
go.temporal.io/server/common/metrics/option.go 6 covered LOC · 2 ranges

Open complete file

10 type WithDescription string
11
12 > func (h WithDescription) apply(m *metricDefinition) { option.go
13 > m.description = string(h)
14 > }
15
16 // WithUnit sets the unit of a metric. See NewBytesHistogramDef for an example.
17 type WithUnit MetricUnit
18
19 > func (h WithUnit) apply(m *metricDefinition) { option.go
20 > m.unit = MetricUnit(h)
21 > }
go.temporal.io/server/common/persistence/data_interfaces.go 6 covered LOC · 3 ranges

Open complete file

1408 // UnixMilliseconds returns t as a Unix time, the number of milliseconds elapsed since January 1, 1970 UTC.
1409 // It should be used for all CQL timestamp.
1410 > func UnixMilliseconds(t time.Time) int64 { data_interfaces.go
1411 > // Handling zero time separately because UnixNano is undefined for zero times.
1412 > if t.IsZero() {
1413 return 0
1414 }
1415
1416 > unixNano := t.UnixNano() data_interfaces.go
1417 > if unixNano < 0 {
1418 // Time is before January 1, 1970 UTC
1419 return 0
1420 }
1421 > return unixNano / int64(time.Millisecond) data_interfaces.go
1422 }
1423
go.temporal.io/server/common/persistence/nosql/nosqlplugin/cassandra/translator/fixed_address_translator.go 6 covered LOC · 2 ranges

Open complete file

15 )
16
17 > func init() { fixed_address_translator.go
18 > RegisterTranslator(fixedTranslatorName, NewFixedAddressTranslatorPlugin())
19 > }
20
21 type FixedAddressTranslatorPlugin struct {
22 }
23
24 > func NewFixedAddressTranslatorPlugin() TranslatorPlugin { fixed_address_translator.go
25 > return &FixedAddressTranslatorPlugin{}
26 > }
27
28 // GetTranslator What gocql driver does is that it will connect to the first node in the list in configuration
go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite/plugin.go 6 covered LOC · 1 range

Open complete file

43 }
44
45 > func init() { plugin.go
46 > sql.RegisterPlugin(PluginName, &plugin{
47 > queryConverter: &queryConverter{},
48 > connPool: newConnPool(),
49 > })
50 > }
51
52 func (p *plugin) GetVisibilityQueryConverter() sqlplugin.VisibilityQueryConverter {
go.temporal.io/server/common/persistence/transitionhistory/transition_history.go 6 covered LOC · 5 ranges

Open complete file

51 func Compare(
52 a, b *persistencespb.VersionedTransition,
53 > ) int { transition_history.go
54 > if a.GetNamespaceFailoverVersion() < b.GetNamespaceFailoverVersion() {
55 return -1
56 }
57 > if a.GetNamespaceFailoverVersion() > b.GetNamespaceFailoverVersion() { transition_history.go
58 return 1
59 }
60
61 > if a.GetTransitionCount() < b.GetTransitionCount() { transition_history.go
62 return -1
63 }
64 > if a.GetTransitionCount() > b.GetTransitionCount() { transition_history.go
65 return 1
66 }
67
68 > return 0 transition_history.go
69 }
70
go.temporal.io/server/common/testing/testvars/const.go 6 covered LOC · 2 ranges

Open complete file

4 }
5
6 > func newGlobal() Global { const.go
7 > return Global{}
8 > }
9
10 > func (c Global) ClusterName() string { const.go
11 > return "active"
12 > }
13
14 func (c Global) RemoteClusterName() string {
go.temporal.io/server/service/history/tasks/chasm_task.go 6 covered LOC · 2 ranges

Open complete file

39 }
40
41 > func (t *ChasmTaskPure) GetCategory() Category { chasm_task.go
42 > return CategoryTimer
43 > }
44
45 func (t *ChasmTaskPure) GetType() enumsspb.TaskType {
82 var _ HasDestination = &ChasmTask{}
83
84 > func (t *ChasmTask) GetCategory() Category { chasm_task.go
85 > return t.Category
86 > }
87
88 func (t *ChasmTask) GetType() enumsspb.TaskType {
go.temporal.io/server/service/history/tasks/key.go 6 covered LOC · 1 range

Open complete file

35 }
36
37 > func NewKey(fireTime time.Time, taskID int64) Key { key.go
38 > return Key{
39 > FireTime: fireTime,
40 > TaskID: taskID,
41 > }
42 > }
43
44 func ValidateKey(key Key) error {
go.temporal.io/server/chasm/nexus_operation_processor.go 5 covered LOC · 1 range

Open complete file

165
166 // NewNexusEndpointProcessor creates a new NexusEndpointProcessor.
167 > func NewNexusEndpointProcessor() *NexusEndpointProcessor { nexus_operation_processor.go
168 > return &NexusEndpointProcessor{
169 > serviceProcessors: make(map[string]*NexusServiceProcessor),
170 > }
171 > }
172
173 // RegisterServiceProcessor adds a service-level processor to the endpoint keyed by its name.
go.temporal.io/server/common/metrics/registry.go 5 covered LOC · 1 range

Open complete file

43
44 // register adds a metric definition to the list of pending metric definitions. This method is thread-safe.
45 > func (c *registry) register(d metricDefinition) { registry.go
46 > c.Lock()
47 > defer c.Unlock()
48 > c.definitions = append(c.definitions, d)
49 > }
50
51 // buildCatalog builds a catalog from the list of pending metric definitions. It is safe to call this method multiple
go.temporal.io/server/common/persistence/sql/sqlplugin/mysql/plugin.go 5 covered LOC · 1 range

Open complete file

24 var _ sqlplugin.Plugin = (*plugin)(nil)
25
26 > func init() { plugin.go
27 > sql.RegisterPlugin(PluginName, &plugin{
28 > queryConverter: &queryConverter{},
29 > })
30 > }
31
32 func (p *plugin) GetVisibilityQueryConverter() sqlplugin.VisibilityQueryConverter {
go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite/conn_pool.go 5 covered LOC · 1 range

Open complete file

23 }
24
25 > func newConnPool() *connPool { conn_pool.go
26 > return &connPool{
27 > pool: make(map[string]entry),
28 > }
29 > }
30
31 // Allocate allocates the shared database in the pool or returns already exists instance with the same DSN. If instance
go.temporal.io/server/common/testing/testvars/hash.go 5 covered LOC · 1 range

Open complete file

5 )
6
7 > func hash(s string) uint32 { hash.go
8 > h := fnv.New32a()
9 > _, _ = h.Write([]byte(s))
10 > return h.Sum32()
11 > }
go.temporal.io/server/common/log/with_logger.go 4 covered LOC · 2 ranges

Open complete file

14 // With returns Logger instance that prepend every log entry with tags. If logger implements
15 // WithLogger it is used, otherwise every log call will be intercepted.
16 > func With(logger Logger, tags ...tag.Tag) Logger { with_logger.go
17 > if wl, ok := logger.(WithLogger); ok {
18 > return wl.With(tags...) with_logger.go
19 > }
20 return newWithLogger(logger, tags...)
21 }
go.temporal.io/server/common/persistence/sql/sqlplugin/mysql/typeconv.go 4 covered LOC · 2 ranges

Open complete file

33 }
34
35 > func getMinMySQLDateTime() time.Time { typeconv.go
36 > t, err := time.Parse(time.RFC3339, "1000-01-01T00:00:00Z")
37 > if err != nil {
38 return time.Unix(0, 0).UTC()
39 }
40 > return t.UTC() typeconv.go
41 }
go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/typeconv.go 4 covered LOC · 2 ranges

Open complete file

35 }
36
37 > func getMinPostgreSQLDateTime() time.Time { typeconv.go
38 > t, err := time.Parse(time.RFC3339, "1000-01-01T00:00:00Z")
39 > if err != nil {
40 return time.Unix(0, 0).UTC()
41 }
42 > return t.UTC() typeconv.go
43 }
go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite/typeconv.go 4 covered LOC · 2 ranges

Open complete file

33 }
34
35 > func getMinSQLiteDateTime() time.Time { typeconv.go
36 > t, err := time.Parse(time.RFC3339, "1000-01-01T00:00:00Z")
37 > if err != nil {
38 return time.Unix(0, 0).UTC()
39 }
40 > return t.UTC() typeconv.go
41 }
go.temporal.io/server/api/persistence/v1/predicates.go-helpers.pb.go 3 covered LOC · 1 range

Open complete file

17
18 // Size returns the size of the object, in bytes, once serialized
19 > func (val *Predicate) Size() int { predicates.go-helpers.pb.go
20 > return proto.Size(val)
21 > }
22
23 // Equal returns whether two Predicate values are equivalent by recursively
go.temporal.io/server/common/cache/size_getter.go 3 covered LOC · 2 ranges

Open complete file

14 )
15
16 > func getSize(value any) int { size_getter.go
17 > if v, ok := value.(SizeGetter); ok {
18 return v.CacheSize()
19 }
20 // if the object does not have a CacheSize() method, assume is count limit cache, which size should be 1
21 > return 1 size_getter.go
22 }
go.temporal.io/server/common/dynamicconfig/key.go 3 covered LOC · 1 range

Open complete file

13 )
14
15 > func MakeKey(s string) Key { key.go
16 > return Key{handle: unique.Make(strings.ToLower(s))}
17 > }
18
19 func (k Key) String() string {
go.temporal.io/server/common/metrics/metrics.go 3 covered LOC · 3 ranges

Open complete file

80 )
81
82 > func (c CounterFunc) Record(v int64, tags ...Tag) { c(v, tags...) } metrics.go
83 > func (c GaugeFunc) Record(v float64, tags ...Tag) { c(v, tags...) } metrics.go
84 > func (c TimerFunc) Record(v time.Duration, tags ...Tag) { c(v, tags...) } metrics.go
85 func (c HistogramFunc) Record(v int64, tags ...Tag) { c(v, tags...) }
go.temporal.io/server/common/payload/payload.go 3 covered LOC · 1 range

Open complete file

30 }
31
32 > func Encode(value any) (*commonpb.Payload, error) { payload.go
33 > return defaultDataConverter.ToPayload(value)
34 > }
35
36 func Decode(p *commonpb.Payload, valuePtr any) error {
go.temporal.io/server/common/persistence/nosql/nosqlplugin/cassandra/translator/translator_plugin.go 3 covered LOC · 1 range

Open complete file

22 // RegisterPlugin adds an auth plugin to the plugin registry
23 // it is only safe to use from a package init function
24 > func RegisterTranslator(name string, plugin TranslatorPlugin) { translator_plugin.go
25 > translators[name] = plugin
26 > }
27
28 func LookupTranslator(name string) (TranslatorPlugin, error) {
go.temporal.io/server/common/persistence/persistence_rate_limited_clients.go 3 covered LOC · 1 range

Open complete file

go.temporal.io/server/common/persistence/sql/store.go 3 covered LOC · 2 ranges

Open complete file

19
20 // RegisterPlugin will register a SQL plugin
21 > func RegisterPlugin(pluginName string, plugin sqlplugin.Plugin) { store.go
22 > if _, ok := supportedPlugins[pluginName]; ok {
23 panic("plugin " + pluginName + " already registered")
24 }
25 > supportedPlugins[pluginName] = plugin store.go
26 }
27
go.temporal.io/server/common/tasks/priority.go 3 covered LOC · 1 range

Open complete file

77 func getPriority(
78 class, subClass Priority,
79 > ) Priority { priority.go
80 > return class | subClass
81 > }
go.temporal.io/server/service/history/queues/errors/errors.go 3 covered LOC · 1 range

Open complete file

39
40 // NewUnprocessableTaskError returns a new UnprocessableTaskError from given message.
41 > func NewUnprocessableTaskError(message string) *UnprocessableTaskError { errors.go
42 > return &UnprocessableTaskError{Message: message}
43 > }
44
45 func (e UnprocessableTaskError) Error() string {
go.temporal.io/server/service/history/tasks/category.go 3 covered LOC · 1 range

Open complete file

100 }
101
102 > func (c Category) Name() string { category.go
103 > return c.name
104 > }
105
106 func (c Category) Type() CategoryType {
go.temporal.io/server/common/log/panic.go 2 covered LOC · 1 range

Open complete file

13 // We have to use pointer is because in golang: "recover return nil if was not called directly by a deferred function."
14 // And we have to set the returned error otherwise our handler will return nil as error which is incorrect
15 > func CapturePanic(logger Logger, retError *error) { panic.go
16 > if panicObj := recover(); panicObj != nil {
17 err, ok := panicObj.(error)
18 if !ok {
go.temporal.io/server/common/persistence/client/fx.go 2 covered LOC · 1 range

Open complete file

224 }
225
226 > func managerProvider[T persistence.Closeable](newManagerFn func(Factory) (T, error)) func(Factory, fx.Lifecycle) (T, error) { fx.go
227 > return func(f Factory, lc fx.Lifecycle) (T, error) {
228 manager, err := newManagerFn(f) // passing receiver (Factory) as first argument.
229 if err != nil {
go.temporal.io/server/common/aggregate/noop_moving_window_average.go 1 covered LOC · 1 range

Open complete file

7 )
8
9 > func newNoopMovingWindowAverage() *noopMovingWindowAverage { return &noopMovingWindowAverage{} } noop_moving_window_average.go
10
11 func (a *noopMovingWindowAverage) Record(_ int64) {}
go.temporal.io/server/common/persistence/noop_health_signal_aggregator.go 1 covered LOC · 1 range

Open complete file

11 )
12
13 > func newNoopSignalAggregator() *noopSignalAggregator { return &noopSignalAggregator{} } noop_health_signal_aggregator.go
14
15 func (a *noopSignalAggregator) Start() {}