Route example / First impressions

111 views
Skip to first unread message

André Farina

unread,
Mar 9, 2023, 11:51:54 AM3/9/23
to Service Weaver
Hi guys,

Thanks for making this project OS.

I started learning Weaver and here are some points that I would like to share:

1 - The documentation states that route invocations on the same replica are not guaranteed, this is true for the 'factors' cache example, which does not depend on routing correctness, however, on 'onlineboutique' example CartCache depends on this. So I modified the code to use a distributed cache https://github.com/andref5/weaver/blob/refact/local-cache/examples/onlineboutique/cartservice/cache.go and I was wondering if it's worth creating a PR.

2 - While I was editing 'CartCache' it broke 'weaver_gen.go' and 'go generate' fails and I manually needed to delete this file. The documentation recommends 'go generate' and I don't know if this approach will be good for large codebases.

3 - While I was coding the cache for Redis, I looked for a function in Weaver to do marshal(LPush) and unmarshal (LRange), looking at the generated codes I would have to preallocate a buffer (codegen pkg). I ended up using json.Marsharl/Unmarshal and wondered if it wouldn't be interesting for the Weaver to have a more generic function that accepts a []byte to use outside of method calls.

Thanks,

André Farina

unread,
Apr 15, 2023, 12:38:36 PM4/15/23
to Service Weaver
Hi guys, 

Hello everyone,

While analyzing the k8s code for generating for deepcopy, I noticed that the following comment tags are added to the generated code:
// go:build !ignore_autogenerated
// +build !ignore_autogenerated

Perhaps adding these tags in the generatior.go file could help with the issue I encountered in point 2.

Srdjan Petrovic

unread,
Apr 17, 2023, 1:50:49 PM4/17/23
to Service Weaver
Hi Andre,

Sorry for the late reply, and thanks for trying out the online boutique app!

Hi guys, 

Hello everyone,

While analyzing the k8s code for generating for deepcopy, I noticed that the following comment tags are added to the generated code:
// go:build !ignore_autogenerated
// +build !ignore_autogenerated

Perhaps adding these tags in the generatior.go file could help with the issue I encountered in point 2.

Thanks for your suggestion, we are in the process of doing something exactly like this!
 

On Thursday, March 9, 2023 at 1:51:54 PM UTC-3 André Farina wrote:
Hi guys,

Thanks for making this project OS.

I started learning Weaver and here are some points that I would like to share:

1 - The documentation states that route invocations on the same replica are not guaranteed, this is true for the 'factors' cache example, which does not depend on routing correctness, however, on 'onlineboutique' example CartCache depends on this. So I modified the code to use a distributed cache https://github.com/andref5/weaver/blob/refact/local-cache/examples/onlineboutique/cartservice/cache.go and I was wondering if it's worth creating a PR.

You are right: the example is indeed breaking our own routing assumptions. The routing promise is "best-effort", so we need to rely on a database (e.g., Redis in your example) to ensure that the cart reads/writes are accurate.

This example should ideally be runnable locally as well, so I'm thinking that maybe we use a simple SQL database (e.g., SQLite) locally, and use CloudSQL on GKE. What do you think?
 

2 - While I was editing 'CartCache' it broke 'weaver_gen.go' and 'go generate' fails and I manually needed to delete this file. The documentation recommends 'go generate' and I don't know if this approach will be good for large codebases.

Yes, we just ran into this ourselves and are working on a fix!
 

3 - While I was coding the cache for Redis, I looked for a function in Weaver to do marshal(LPush) and unmarshal (LRange), looking at the generated codes I would have to preallocate a buffer (codegen pkg). I ended up using json.Marsharl/Unmarshal and wondered if it wouldn't be interesting for the Weaver to have a more generic function that accepts a []byte to use outside of method calls.

Interesting, we haven't thought about making the marshal/unmarshal calls public. We'll look into it.
 

Thanks,
Reply all
Reply to author
Forward
0 new messages