go.temporal.io/server/common/protocol/naming.go

75 LOC · 24 covered · 51 uncovered · 11 ranges · 41 concepts · 8 introducers · 19 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileapi.go ×2 · 8 introduced LOCapi.go ×2workflow_task_state_machine.go ×1 · 4 introduced LOCworkflow_task_state_mach…Two_page_completion_merges_commands · 0 introduced LOCTwo_page_completion_merg…api.go ×2 · 3 introduced LOCapi.go ×2Accept_Complete · 0 introduced LOCAccept_Completeapi.go ×1 · 1 introduced LOCapi.go ×1Write_failed_on_normal_task_queue · 0 introduced LOCWrite_failed_on_normal_t…api.go ×4 · 29 introduced LOCapi.go ×4test_vars.go ×1 · 7 introduced LOCtest_vars.go ×1update.go ×2 · 4 introduced LOCupdate.go ×2update.go ×1 · 5 introduced LOCupdate.go ×1workflow_task_state_machine.go ×1 · 5 introduced LOCworkflow_task_state_mach…mutable_state_impl.go ×20 · 150 introduced LOCmutable_state_impl.go ×2…Discard_speculative_WFT_with_events · 0 introduced LOCDiscard_speculative_WFT_…test_vars.go ×1 · 3 introduced LOCtest_vars.go ×1workflow_task_state_machine.go ×2 · 26 introduced LOCworkflow_task_state_mach…history_require.go ×1 · 1 introduced LOChistory_require.go ×1Reject · 0 introduced LOCRejectindexedtakelist.go ×1 · 30 introduced LOCindexedtakelist.go ×1workflow_task_state_machine.go ×1 · 1 introduced LOCworkflow_task_state_mach…indexedtakelist.go ×1 · 13 introduced LOCindexedtakelist.go ×1mutable_state_mock.go ×2 · 11 introduced LOCmutable_state_mock.go ×2workflow_task_completed_handler.go ×1 · 3 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×1 · 1 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×2 · 7 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×1 · 4 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×2 · 16 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×1 · 1 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×1 · 2 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×2 · 4 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×1 · 1 introduced LOCworkflow_task_completed_…workflow_task_completed_handler.go ×2 · 9 introduced LOCworkflow_task_completed_…TestWithValidMessage · 0 introduced LOCTestWithValidMessagenaming.go ×1 · 3 introduced LOCnaming.go ×1naming.go ×3 · 7 introduced LOCnaming.go ×3naming.go ×1 · 2 introduced LOCnaming.go ×1naming.go ×1 · 1 introduced LOCnaming.go ×1naming.go ×1 · 2 introduced LOCnaming.go ×1naming.go ×1 · 2 introduced LOCnaming.go ×1naming.go ×1 · 4 introduced LOCnaming.go ×1naming.go ×2 · 3 introduced LOCnaming.go ×2nil_message · introduced test · go.temporal.io/server/common/protocol/TestNilSafety/nil_messagenil_messagenil_message_body · introduced test · go.temporal.io/server/common/protocol/TestNilSafety/nil_message_bodynil_message_bodyTestWithInvalidBody · introduced test · go.temporal.io/server/common/protocol/TestWithInvalidBodyTestWithInvalidBodyTestWithValidMessage · introduced test · go.temporal.io/server/common/protocol/TestWithValidMessageTestWithValidMessagedeliver_message_failure · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestCommandProtocolMessage/deliver_message_failuredeliver_message_failuredeliver_message_success · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestCommandProtocolMessage/deliver_message_successdeliver_message_successmessage_for_unsupported_protocol · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestCommandProtocolMessage/message_for_unsupported_protocolmessage_for_unsupported_…message_too_large · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestCommandProtocolMessage/message_too_largemessage_too_largeupdate_not_found · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestCommandProtocolMessage/update_not_foundupdate_not_foundAccept_Complete · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/Accept_CompleteAccept_CompleteDiscard_speculative_WFT_with_events · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/Discard_speculative_WFT_with_eventsDiscard_speculative_WFT_…Do_not_discard_speculative_WFT_with_more_than_10_events · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/Do_not_discard_speculative_WFT_with_more_than_10_eventsDo_not_discard_speculati…GetHistory_failed · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/GetHistory_failedGetHistory_failedReject · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/RejectRejectWrite_failed_on_normal_task_queue · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/Write_failed_on_normal_task_queueWrite_failed_on_normal_t…Write_failed_on_sticky_task_queue · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestUpdateWorkflow/Write_failed_on_sticky_task_queueWrite_failed_on_sticky_t…Duplicate_intermediate_page_is_idempotent · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestWorkflowTaskCompletionPagination/Duplicate_intermediate_page_is_idempotentDuplicate_intermediate_p…Single_page_completion_unchanged_when_pagination_enabled · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestWorkflowTaskCompletionPagination/Single_page_completion_unchanged_when_pagination_enabledSingle_page_completion_u…Two_page_completion_merges_commands · introduced test · go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/TestWorkflowTaskCompletedHandlerSuite/TestWorkflowTaskCompletionPagination/Two_page_completion_merges_commandsTwo_page_completion_merg…Focused file · go.temporal.io/server/common/protocol/naming.go · 75 LOCprotocol/naming.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package protocol
2
3 import (
4 "fmt"
5 "strings"
6
7 protocolpb "go.temporal.io/api/protocol/v1"
8 )
9
10 type (
11 // Type is a protocol type of which there may be many instances like the
12 // update protocol or the query protocol.
13 Type string
14
15 // MessageType is the type of a message within a protocol.
16 MessageType string
17
18 constErr string
19 )
20
21 const (
22 MessageTypeUnknown = MessageType("__message_type_unknown")
23 TypeUnknown = Type("__protocol_type_unknown")
24
25 errNilMsg = constErr("nil message")
26 errNilBody = constErr("nil message body")
27 errProtoFmt = constErr("failed to extract protocol type")
28 errNoName = constErr("no message name specified")
29 )
30
31 // String transforms a MessageType into a string
32 > func (mt MessageType) String() string { naming.go ×3
33 > return string(mt)
34 > }
35
36 // String tranforms a Type into a string
37 > func (pt Type) String() string { naming.go ×1
38 > return string(pt)
39 > }
40
41 // Identify is a function that given a protocol message gives the specific
42 // message type of the body and the type of the protocol to which this message
43 // belongs.
44 > func Identify(msg *protocolpb.Message) (Type, MessageType, error) { naming.go ×2
45 > if msg == nil {
46 > return TypeUnknown, MessageTypeUnknown, errNilMsg naming.go ×1
47 > } else if msg.Body == nil { naming.go ×2
48 > return TypeUnknown, MessageTypeUnknown, errNilBody naming.go ×1
49 > }
50
51 > bodyTypeName := string(msg.Body.MessageName()) naming.go ×1
52 > if bodyTypeName == "" {
53 > return TypeUnknown, MessageTypeUnknown, errNoName naming.go ×1
54 > }
55
56 > msgType := MessageType(bodyTypeName) naming.go ×3
57 > lastDot := strings.LastIndex(bodyTypeName, ".")
58 > if lastDot < 0 {
59 err := fmt.Errorf("%w: no . found in %q", errProtoFmt, bodyTypeName)
60 return TypeUnknown, msgType, err
61 }
62 > return Type(bodyTypeName[0:lastDot]), msgType, nil naming.go ×3
63 }
64
65 // IdentifyOrUnknown wraps Identify to return TypeUnknown and/or
66 // MessageTypeUnknown in the case where either one cannot be determined due to
67 // an error.
68 > func IdentifyOrUnknown(msg *protocolpb.Message) (Type, MessageType) { naming.go ×1
69 > pt, mt, _ := Identify(msg)
70 > return pt, mt
71 > }
72
73 func (cerr constErr) Error() string {
74 return string(cerr)
75 }