Skip to content

Add entity support#14

Merged
sebastianburckhardt merged 14 commits intomainfrom
entities
Sep 11, 2023
Merged

Add entity support#14
sebastianburckhardt merged 14 commits intomainfrom
entities

Conversation

@sebastianburckhardt
Copy link
Member

Adds required protocols for supporting entities. This includes requests/responses for client-initiated entity-related operations, and the new workitem definitions for entity work items.

string name = 2;
google.protobuf.StringValue input = 3;
bytes guid = 4;
bool hasScheduledTime = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? Can we not test null on scheduledTime?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no null for google.protobuf.Timestamp.

That said, I have started using default to represent null in the queries. I can do that here as well.

Copy link
Member

@jviau jviau Sep 8, 2023

Choose a reason for hiding this comment

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

In C# Timestamp from Google.Protobuf is a class, so it is nullable. We use it as null throughout durabletask-dotnet. Public APIs use DateTimeOffset? to map a nullable time.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am a bit concerned about the defaults not matching up (null vs. default(DateTime) vs default-of-Google-Protobuf-Timestamp-in-other-languages) and this coming to bite us later. This is why I had introduced a bool hasDateTime.

We need to make sure I think that we are not using a dotnet-specific convention.

Copy link
Member Author

Choose a reason for hiding this comment

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

In C# Timestamp from Google.Protobuf is a class, so it is nullable

I find this quite confusing. I am pretty sure that the google timestamp datatype has no null, so I am not sure how this is made sure to round-trip correctly. Maybe a null DateTime would be transmitted as certain Timestamp value and then that certain timestamp value is turned back into null at the other end? But if so, what is that certain value? Is it the default of the DateTime in C#? or the default (two zeros) of Google's internal representation of Timestamp? or whatever other languages (e.g. Java) would consider a default? To save us from having to answer these questions is why I was introducing a hasTimestamp field. Unless I get conclusive answers I may have to bring it back.

Copy link
Member

@jviau jviau Sep 11, 2023

Choose a reason for hiding this comment

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

I am pretty sure that the google timestamp datatype has no null

Timestamp is a class, so it can be null.

And here is our null usage of it: https://github.com/microsoft/durabletask-dotnet/blob/main/src/Shared/Grpc/ProtoUtils.cs#L202. Note that it is Timestamp? (with the ?) only because we are using explicit nullability.

Copy link
Member Author

Choose a reason for hiding this comment

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

Timestamp is a class, so it can be null

The point was that the official Google Timestamp datatype and its protobuf representation have no concept of null, it really does not matter what is happening in C#. Maybe someone somewhere made a choice as to how the C# null should be represented on the wire. This choice is not a "standard" choice and we need to be aware of its consequences. Have you tested that null roundtrips correctly? And how do we handle this issue when using Java?

Copy link
Member Author

@sebastianburckhardt sebastianburckhardt Sep 11, 2023

Choose a reason for hiding this comment

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

I am pretty sure that if you set Timestamp to null, send it across the wire, and then read it from the wire, you get a new Timestamp() back - not null. This would be midnight January 1st, 1970, I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am going to add explicit conversions to make this 100% clear.

Copy link
Member

Choose a reason for hiding this comment

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

I just verified - you get null on the other end. While protobuf forbids null fields, Timestamp is not a field, it is a message. And messages can be null via omission. And this is what we are doing, omitting the Timestamp message via null.


message OperationRequest {
string operation = 1;
bytes guid = 2;
Copy link
Member

Choose a reason for hiding this comment

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

nit: use a name like uniqueId or just id, as "guid" is not universally used - some languages call it UUID

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I think this should be requestId I think.

Copy link
Member

Choose a reason for hiding this comment

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

Also, can we use string here? We use that for the various IDs in the proto file already. Not sure what bytes offers over that.

Copy link
Member Author

@sebastianburckhardt sebastianburckhardt Sep 11, 2023

Choose a reason for hiding this comment

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

byte requires half the space. This is significant when processing large batches of entity operations (I already felt kind of bad for adding a large Guid to each operation).

we can reevaluate this question once we have the benchmarks running.

Copy link
Member

Choose a reason for hiding this comment

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

I found this as a good argument for using string: https://stackoverflow.com/questions/36344826/how-do-i-represent-a-uuid-in-a-protobuf-message

In short: bytes may cause issues between different languages as their UUID implementation encoding/decoding may be different.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like it but it is true that it will cause headaches with Java, so I suppose using string is better.

sebastianburckhardt added a commit to microsoft/durabletask-dotnet that referenced this pull request Sep 7, 2023
sebastianburckhardt added a commit to microsoft/durabletask-dotnet that referenced this pull request Sep 7, 2023
@sebastianburckhardt sebastianburckhardt merged commit 9d9ac8a into main Sep 11, 2023
@sebastianburckhardt sebastianburckhardt deleted the entities branch September 11, 2023 23:40
sebastianburckhardt added a commit to microsoft/durabletask-dotnet that referenced this pull request Sep 14, 2023
…n. (#186)

* add factories

* implement grpc worker

* update to latest core, remove obsolete files

* Apply suggestions from code review

Co-authored-by: Jacob Viau <javia@microsoft.com>

* fix renaming of variables

* address PR feedback

* propagate changes from microsoft/durabletask-protobuf/pull/14

* revise representation of operation results

* update/simplify protobuf utils

* simplify StateShim and ContextShim

* some minor simplifications

* add missing failure details.

* simplify operationActions list useage, by always creating a fresh list when resetting.

* Apply suggestions from code review

Co-authored-by: Jacob Viau <javia@microsoft.com>

---------

Co-authored-by: Jacob Viau <javia@microsoft.com>
sebastianburckhardt added a commit to microsoft/durabletask-dotnet that referenced this pull request Sep 21, 2023
* draft

* implement client

* simplify query

* propagate changes from microsoft/durabletask-protobuf/pull/14

* Apply suggestions from code review

Co-authored-by: Jacob Viau <javia@microsoft.com>

* address PR feedback

* add continuation token to CleanEntityStorage operation

* fix/simplify protobuf format

* minor simplifications

* add optional continueUntilComplete argument to CleanEntityStorageAsync

* update to latest proto

---------

Co-authored-by: Jacob Viau <javia@microsoft.com>
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

Successfully merging this pull request may close these issues.

2 participants