Open apuigsech opened 4 years ago
Sounds good.
This is happening to me, particularly, on the "created" and "updated" fields, because they are initialised using the function Now, which uses time.Now() that considers location on the internal state.
So, other possible solutions is to prevent them to manage the location state by just adding a call to UTC() on the Now function;
Now = func(ctx context.Context, value interface{}) interface{} {
return time.Now()**.UTC()**
}
Thoughts?
Changing the Now
function is defiantly the smallest change. I have no objections to it.
@apuigsech I am :+1: for UTC() time as well.
Etag calculation is done by marshaling the payload into json and getting the md5 of that string. All values will be converted to string, and there are some specific cases in which the conversion to string depends on external state, like its time.Time. Its sting will depend on the local timezone.
This is not an issue if the item is only processed by a single computer (or a set of them on the same timezone), but I found a case in which this is not the case. I am using postgres replica through kafka events to replicate part of the state from one service to another, and both needs to be on different timezone, causing the same item in two different systems to have a different Etags. This is an issue in the moment I am considering the Etag and the Id as the replica identity.
This is the database on service A:
And this is on service B:
I think we should guaranty that for same time.Time's, the Etag will be always the same independently of external states, and I suggest to do something like this on the getEtag function:
If you agree with that I can work on making the a proper PR.