Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial go client #227

Closed
wants to merge 20 commits into from
Closed

Conversation

RRethy
Copy link
Contributor

@RRethy RRethy commented Jan 2, 2023

Follow-up to #226 so the first 16 commits are duplicated from that branch, unfortunately GitHub won't let me use that PR as the base since it's not under aurae-runtime.

This PR adds an initial Go client under client-go. It only has code generate by buf, a future PR (probably some time tmrw or tuesday) will have a more fleshed out client.

The PR boils down to adding this to buf.gen.yaml, and running make proto.

  - plugin: buf.build/protocolbuffers/go:v1.28.1
    out: client-go/pkg/api
    opt: paths=source_relative
  - plugin: buf.build/grpc/go:v1.2.0
    out: client-go/pkg/api
    opt: paths=source_relative

@RRethy RRethy mentioned this pull request Jan 2, 2023
@dmah42
Copy link
Contributor

dmah42 commented Jan 2, 2023

meta comment: I don't think we should be committing generated code.


macros::ops_generator!(
runtime,
cell,
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't right as the generated code will not result in a guaranteed unique, namespaced and predictable name.

  • We have: ae__runtime__cell_service__allocate
  • Here we get: ae__cell__cell_service__allocate
  • We want: ae__runtime_cell__cell_service__allocate

Side note: would we want "cell", "pod" etc. or should they be plural (e.g., "cells", "pods", etc.) which sounds more natural to me? (I don't know what the convention is)

Copy link
Contributor

Choose a reason for hiding this comment

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

Realizing I got this mixed up with auraescript's macro. I still suspect there will be an issue in the generated code. I'll have to pull down the PR to check.

@@ -29,68 +29,10 @@
\* -------------------------------------------------------------------------- */
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that the services are broken into smaller files. Should there be a higher level runtime file? If we have shared messages, where would we put those?

Copy link
Contributor

Choose a reason for hiding this comment

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

the issue i have here is that each broken down part now has its own version, which i don't think is what we want.. we want aurae.. (where service is runtime or runtime.cells, or whatever).

having aurae.. implies that we might have runtime.cells.v1 and observe.v0 which i would like to avoid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely agree with the version being in the wrong spot. I'm also inclined to agree with your comment overall (more context).

My only reason for liking the multiple files is that smaller files are easier to grasp, but that is not a good reason to break things up if it causes other issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I posted a follow-up on the structure, #226 (comment).

@@ -0,0 +1,16 @@
module github.com/aurae-runtime/aurae/client-go
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the go code would be in the ae repo. It doesn't matter to me; I'm just checking that the contributors working on it (I know that includes you) are in agreement that this is the right decision at this point in time.

Side note: @krisnova @dmah42 if we make this repo have more general code, maybe we should consider moving all the rust crates into the crates directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah i had expected this to be in a separate repo. i didn't notice this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the rational behind putting it in a different repo?

My logic for putting it in aurae-runtime/aurae was the following:

  • Keep the source of truth in the same repo to avoid getting out sync
  • The rust and typescript generated code are in this repo as well
  • The proto files will have a option go_package = "..." which points to it's own repo instead of an external repo that can easily break
  • If we want to move the code into another repo, we could follow kubernetes/client-go which just syncs that code from https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/client-go which acts as the source of truth (and lives alongside the types it exposes)

If you all don't want it here though I can close the PR and we can figure out a more appropriate place for it.

export class CellServiceClient implements CellService {
allocate(request: CellServiceAllocateRequest): Promise<CellServiceAllocateResponse> {
// @ts-ignore
return Deno.core.ops.ae__cell__cell_service__allocate(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment incorrectly placed on the aurae-client code

@@ -166,7 +166,7 @@ fn typescript_generator(input: &OpsGeneratorInput) {

let ts_path = {
let mut out_dir = gen_dir.clone();
out_dir.push(format!("v0/{module}.ts"));
out_dir.push(format!("runtime/{module}/v0/{module}.ts"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the correct way to fix the macro as we have more modules than runtime, but if it works in this PR and you are not comfortable making the change, I can fix it after if we merge this as is.

@RRethy
Copy link
Contributor Author

RRethy commented Jan 2, 2023

meta comment: I don't think we should be committing generated code.

Would this apply to the rust/typescript generate code?

I've usually seen gRPC generate code being an exception to that rule. The issue I'd see with not committing the generated code is that if we provide a client wrapper around the generated code (similar to https://github.com/aurae-runtime/client-go/blob/main/client.go), it would break downloading the code with go get .../client-go since the code wouldn't be generated for downstream users.

@dmah42
Copy link
Contributor

dmah42 commented Jan 2, 2023

meta comment: I don't think we should be committing generated code.

Would this apply to the rust/typescript generate code?

I've usually seen gRPC generate code being an exception to that rule. The issue I'd see with not committing the generated code is that if we provide a client wrapper around the generated code (similar to https://github.com/aurae-runtime/client-go/blob/main/client.go), it would break downloading the code with go get .../client-go since the code wouldn't be generated for downstream users.

it does apply to that, yes. in fact we don't have that generated code at head any more.

perhaps this removal was a mistake.. i wasn't aware that go required the generation to be checked in. that's less than ideal (it makes for noisy commits, merge issues, and sometimes people forget to generate the code before committing).

unless we have some github workflow that generates the code and checks it in instead, but that's an education problem.

@future-highway
Copy link
Contributor

meta comment: I don't think we should be committing generated code.

Would this apply to the rust/typescript generate code?

Just answering ^^^

Yes, I would expect it to apply to all generated code. The only benefit I'm seeing from checking in generated code is that I can see that changes in the generators are outputting the expected result. However, that can't even be trusted. How can we be sure a PR generated the code as the last change before pushing? I think I've made the mistake before where I didn't include the changes in the generated code in the PR. If someone pulled the source at that point, the generated code would be correct only after running the build.

I don't know/haven't considered if an exception is warranted.

@krisnova
Copy link
Contributor

krisnova commented Jan 2, 2023

Are we putting Go code in this repository now?

I thought we had decided to put the client-go here as per the aurae-runtime/ae#13 (comment).

@RRethy
Copy link
Contributor Author

RRethy commented Jan 2, 2023

Are we putting Go code in this repository now?

I thought we had decided to put the client-go here as per the aurae-runtime/ae#13 (comment).

Ah I didn't see that issue, I'll close this and move discussion into that issue.

@RRethy RRethy closed this Jan 2, 2023
@krisnova
Copy link
Contributor

krisnova commented Jan 2, 2023

@RRethy please mention either in the Discord or on the issue that you intend on working on it. I know other people are also considering this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants