-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Name method to ReceiveChannel and SendChannel interface #1538
add Name method to ReceiveChannel and SendChannel interface #1538
Conversation
|
internal/workflow.go
Outdated
@@ -66,8 +66,16 @@ var ( | |||
) | |||
|
|||
type ( | |||
// commonChannel contains methods common to both SendChannel and ReceiveChannel | |||
commonChannel interface { | |||
// Name returns the name of the channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a few things to the docs:
- Specify that for a
SignalChannel
,Name
is the signal name. Some places in Temporal refer to signal "Name" as "Type" so it may not obvious. - Specify that channels created without an explicit name have a name generated by the SDK and they should not assume it is deterministic. Normally all workflow APIs are deterministic, but in this case the channel name would not be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added clarity to the documentation as requested
Overall LGTM, just a couple of documentation points. |
internal/workflow.go
Outdated
// SendChannel is a write only view of the Channel | ||
SendChannel interface { | ||
commonChannel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be on the receive side only (send channel only used if user explicitly chooses to break it up, and they can't get things like Len()
either even though technically we could provide it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to restrict Name
to only receive side channels? A sender could be interested in them name as much as the receiver is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering aloud. Can ask the same of Len
. Go allows you to get len
and cap
on both recv-only and send-only channels but we decided Len()
should only be on receive. I just wonder if we need to apply whatever that thought process is here. I don't mind if that same thing shouldn't apply here and we put Name()
on both (though I think it'd be worth copying the definition twice vs making a new interface).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our use-case we only use Name
for the SendChannel
case, so if anything I'd only want it on the SendChannel
.
internal/workflow.go
Outdated
// SendChannel is a write only view of the Channel | ||
SendChannel interface { | ||
commonChannel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if, even though we use aliases which make this harder, inlining the Name()
method with the docs is clearer than a shared interface. It's just two places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will make the change if there's agreement between @Quinn-With-Two-Ns and yourself :)
One readability benefit of sharing the interface is it'll ensure documentation remains synced over time if it gets modified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think inlining is better for readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and inlined. Also made tests explicitly test ReceiveChannel
and SendChannel
interfaces with Name
// A Channel created without an explicit name will use a generated name by the SDK and | ||
// is not deterministic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// A Channel created without an explicit name will use a generated name by the SDK and | |
// is not deterministic. | |
// A Channel created without an explicit name will use a generated name by the SDK and | |
// is deterministic. |
It is deterministic correct? (built from channel sequence)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not given our normal definition for what is deterministic, and I would not want suers to have any expectation of the SDK generated name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our normal definition is "same during replay" I thought. Definitely no expectation of generated name, but it's still deterministic. Maybe we should just say "generated name by the SDK" without any additional info about determinism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even just creating another channel would change the value, we generally don't say creating a channel or switching the order you create channels in not deterministic.
c3bf2b8
to
eb6ac13
Compare
…plicitly tests Name call
If there's anything else outstanding / blocking merge, please let me know :) |
Thanks, merged! |
What was changed
Name
method toSendChannel
andReceiveChannel
interfaceName
returns back the same given name.Why?
channel.Send
method, ideally we could simplify our API to not require a redundant sending of the channelName again.telemetrytemporal.ChannelSend[T](ctx workflow.Context, channel workflow.SendChannel, channelName string, payload T)
Checklist
Closes #1304
internal/internal_coroutines_test.go
which creates named channels and asserts that theName
method returns back the same name you gave it.