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

Custom Storage Provider: PubSubGrainState is internal so cannot be stored #9222

Open
nkosi23 opened this issue Nov 9, 2024 · 1 comment
Open

Comments

@nkosi23
Copy link

nkosi23 commented Nov 9, 2024

I am facing a challenge that I struggle to overcome.

I have implemented a custom storage provider, using an underlying data store that requires all documents being saved to have an Id property.

Since I use external libraries also using Orleans to persist state, I have added logic so that if the State type has an id field it is stored as is, otherwise, the state is wrapped in a generic wrapper type looking like the below:

type GrainStateWrapper<'T> = { Id: string; State: 'T }

Apparently, internally Orleans uses the PubSubGrainState as part of the streaming feature. Since this type does not have an Id property I need to wrap it, however I am getting a runtime issue when persisting the wrapper because the type is inaccessible as it is indeed marked as internal.

This also creates issues because the storage library I am using relies on a fluent API to discover and configure the types being persisted, but once again since the type is internal I cannot do that. I do not understand why a type needing to be persisted would be marked as internal.

Anyway, I wonder what my options are, as it doesn't look like I can easily swap the PubSubGrainState for another type.

Any idea would be greatly appreciated!

Thanks

@nkosi23
Copy link
Author

nkosi23 commented Nov 10, 2024

I have worked around this issue by using IGrainStorageSerializer.Serialize(state) to serialize this state as a base64 string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant