Skip to content
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 Sample for Typed equivalents for workflow.* functions/interfaces using generics #313

Open
ndtretyak opened this issue Oct 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ndtretyak
Copy link

ndtretyak commented Oct 30, 2023

Is your feature request related to a problem? Please describe.
Currently, there are a lot of interfaces and functions (e.g., side effects and channels) accepting or returning interface{}. I believe that with generics, it is possible to provide Typed equivalents for these interfaces, enhancing type safety.

Describe the solution you'd like
For instance, a side effect could take a typed function f and return f() directly instead of some converter.EncodedValue

func TypedSideEffect[T any](ctx Context, f func(ctx Context) T) (T, error)

Describe alternatives you've considered
Implement these typed interfaces in my own code.

@ndtretyak ndtretyak added the enhancement New feature or request label Oct 30, 2023
@Quinn-With-Two-Ns
Copy link
Contributor

We have discussed how generics can make the Go SDK API more type safe. We plan to provide a sample showing how the Go SDK could be wrapped using generics, but we do not plan to add it to the SDK at this time. If the sample receives sufficient interest me may consider graduating it into the SDK in some form, but that is TBD.

@Quinn-With-Two-Ns Quinn-With-Two-Ns transferred this issue from temporalio/sdk-go Oct 30, 2023
@Quinn-With-Two-Ns Quinn-With-Two-Ns changed the title Typed equivalents for workflow.* functions/interfaces Add Sample for Typed equivalents for workflow.* functions/interfaces using generics Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants