What you're dealing with is very similar to etags. The Google Cloud API
design patterns suggests
<https://cloud.google.com/apis/design/design_patterns#etags> "an API should
include a string field etag in the resource definition." Looking at a few
<https://github.com/googleapis/googleapis/blob/3c5166c1db0f1804af7acdbbd79137630a00ce63/google/monitoring/dashboard/v1/dashboard.proto#L43>
 examples
<https://github.com/googleapis/googleapis/blob/f69562be0608904932bdcfbc5ad8b9a22d9dceb8/google/iam/v1/policy.proto#L110>,
you can see the pattern: User would have a rowversion field that would be
set when returned by the service. When being passed to the service to be
modified, the field would be set to the *old* version.

That approach is probably pretty natural in the code, as the client could
do a get(), modify the proto in-place, and then a set(). It wouldn't even
have to copy the rowversion explicitly.

On Tue, Jun 16, 2020 at 3:06 AM Smellblaster <smellblas...@gmail.com> wrote:

> Hello!
>
> Usually I solve concurrency with EF6 so I add Timestamp (rowversion)
> column to all my tables.
> When I try to update value in database I just need to check if value in
> this column is still the same.
>
> Now I want to move CRUD operations to gRPC service.
>
> I have 2 methods
> - User GetUser(int id);
> - UpdateUser(id, User u)
>
> User is my model and is *not directly *mapped to Entity (so there is no
> rowversion field in my model).
> Well. First idea that comes to my mind is to add this rowversion field to
> model also.
>
> Is this correct approach or is there a better way.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to grpc-io+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/db8d097e-fa8c-42e8-9b6c-5ad0f114e817o%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/db8d097e-fa8c-42e8-9b6c-5ad0f114e817o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oN-jd7%3DV%2BZzNKzk6GJGZ2F6bGtdny95GgE8E2kJqy%2BqDg%40mail.gmail.com.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to