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

feat: make replicated data types generic #327

Merged
merged 1 commit into from
May 11, 2022

Conversation

pvlugter
Copy link
Member

@pvlugter pvlugter commented May 11, 2022

Refs #320.

Make replicated data types generic. Replicated entity state is not yet generic, so this is just the underlying step towards that. Entities may need a bit of reworking to have this ripple through the contexts in particular.

The typing for serialized state is still awkward in TypeScript, with it requiring the reflective Message type, but should be able to improve on this and use the generated protobuf directly (see #326).

The type parameters will default to Serializable to have the same behaviour as before. Some tests are updated, others left as is.

Note that this used single letter type parameters at first (T, E, K, V and so on), but the latest TypeScript docs are now using full names, so I've followed the full name convention here as well.

@github-actions github-actions bot added kalix-runtime Runtime and SDKs sub-team typescript-sdk labels May 11, 2022
@@ -35,7 +35,7 @@ export interface TypedJson {
export type Serializable =
| protobuf.Message
| TypedJson
| any
| object
Copy link
Member Author

@pvlugter pvlugter May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means that Serializable is no longer always just any. The handlers and callbacks can't use the Serialiable union type directly now, as it would require the implementation to accept all these types. Entities and their handlers and contexts will also become generic, with a parameter that extends Serializable instead.

@pvlugter pvlugter merged commit 8566a3a into lightbend:main May 11, 2022
@pvlugter pvlugter deleted the generic-replicated-data branch May 11, 2022 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kalix-runtime Runtime and SDKs sub-team typescript-sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants