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

C++ SDK: Use const-reference in WatchGameServer #941

Closed
roberthbailey opened this issue Jul 23, 2019 · 6 comments · Fixed by #951
Closed

C++ SDK: Use const-reference in WatchGameServer #941

roberthbailey opened this issue Jul 23, 2019 · 6 comments · Fixed by #951
Assignees
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/breaking Breaking change kind/cleanup Refactoring code, fixing up documentation, etc
Milestone

Comments

@roberthbailey
Copy link
Member

From #934:

Is it intentional to pass a GameServer object by value? I don't know if this is an expensive type to copy, but it looks like accepting this object by const-reference may be worthwhile.

We should consider changing the function signature of

grpc::Status SDK::WatchGameServer(
    const std::function<void(agones::dev::sdk::GameServer)>& callback) { ... }

Since this would be a breaking change to the CPP SDK, I'm marking this for milestone 0.12.0 and we should resolve to do this (or leave it) ASAP.

@devjgm

@roberthbailey
Copy link
Member Author

@Kuqd / @markmandel - thoughts?

@markmandel
Copy link
Member

markmandel commented Jul 23, 2019

I've no strong opinions. I basically wrote the C++ SDK as a sacrificial draft. Very happy to defer to opinions that have more C++ experience than me.

@devjgm
Copy link
Contributor

devjgm commented Jul 24, 2019

A couple questions:

  1. Does the GameServer argument to the callback need to be mutated? Or could it be const?
  2. Is GameServer a small and cheap type that is most efficiently passed by value?

Depending on the answers to the above, I'd suggest a signature like:

grpc::Status SDK::WatchGameServer(
    const std::function<void(const agones::dev::sdk::GameServer&)>& callback);

@roberthbailey
Copy link
Member Author

  1. My understanding is that it should not need to be mutated as changes to it would not be reflected back into k8s (so mutating it would only be confusing).

  2. I'm not sure where the cut-off is for small/cheap, but GameServer is a generated proto type, so I'm guessing the answer would be no.

@markmandel
Copy link
Member

I can't think of any reason you would want to mutate the gameserver

@roberthbailey roberthbailey self-assigned this Jul 24, 2019
@markmandel markmandel added area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/breaking Breaking change kind/cleanup Refactoring code, fixing up documentation, etc and removed kind/feature New features for Agones labels Jul 24, 2019
@roberthbailey
Copy link
Member Author

If there aren't any dissenting opinions by the end of the day tomorrow I'll send a PR to change the function signature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/breaking Breaking change kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
3 participants