weaver icon indicating copy to clipboard operation
weaver copied to clipboard

Bazel Support

Open lbhdc opened this issue 2 years ago • 6 comments

Hey! I am really interested in exploring how service weaver would fit in a bazel project.

I asked in the bazel slack if there was an integration with service weaver, and it was suggested that perhaps there was internal blaze support.

If that support exists, would it be possible to open source it?

lbhdc avatar Aug 21 '23 15:08 lbhdc

Hi @lbhdc, we do not have any official bazel support.

To build a Service Weaver application, you have to run weaver generate ./... and go build. Does bazel support that?

mwhittaker avatar Aug 21 '23 16:08 mwhittaker

Thanks for such a quick response @mwhittaker!

It does supports something similar to that. The canonical way to build go programs is with the rules_go ruleset which downloads the toolchain, and handles calling go build, go run, or go test. Related rulesets also handle generating all the bazel integrations for third party packages.

https://github.com/bazelbuild/rules_go

As for the weaver command, support in the form of a ruleset is needed to make it available to bazel users.

Just brainstorming the api, but I would imagine using such a ruleset would kinda look like this. A user would add this glob to their BUILD file, and bazel would invoke the weaver command when any of the dependencies have been updated. The code would then be able to be consumed by yet another down stream tools (like kubectl for manifests).

weaver_generate(
  name = "foo",
  deps = [
    "//my/top/level/weaver:component"
  ]
)

lbhdc avatar Aug 21 '23 17:08 lbhdc

I see. Thanks for explaining; I'm not very familiar with bazel. I'll leave the issue open as a TODO then.

mwhittaker avatar Aug 21 '23 17:08 mwhittaker

Thanks, I appreciate it :grin:

lbhdc avatar Aug 21 '23 17:08 lbhdc

If an open source ruleset was developed, would that be something you would be interested in having contributed back to service weaver?

lbhdc avatar Aug 21 '23 17:08 lbhdc

Yeah, for sure!

mwhittaker avatar Aug 22 '23 16:08 mwhittaker