micro / services

Real World Micro Services
Apache License 2.0
1.25k stars 137 forks source link

choosing a neutral keyword for naming in the proto file #387

Open lambdaR opened 2 years ago

lambdaR commented 2 years ago

a new case, similar to #382 accrued when running the dart generate workflow https://github.com/GWT-M3O-TEST/GWT-m3o-dart/runs/5320273604?check_suite_focus=true#step:18:16 .

the keyword 'New' in the protobuf file of the chat service https://github.com/micro/services/blob/a2b7981d637300ef4f74b3c98dff9d718878e2f6/chat/proto/chat.proto#L7

will be converted into

/// Create a new chat room
Future<NewResponse> new(NewRequest req) async {
        Request request = Request(
            service: 'chat',
            endpoint: 'New',
            body: req.toJson(),
        );

        try {
            Response res = await _client.call(request);
            if (isError(res.body)) {
              final err = Merr(res.toJson());
              return NewResponse.Merr(body: err.b);
            }
            return NewResponseData.fromJson(res.body);
          } catch (e) {
            throw Exception(e);
          }
    }

the 'new' keyword, is a reserved optional keyword in dart and the compiler get confused about it.

we need to follow a standard for naming things in protobuf to avoid any conflicts (recommended), or we can handle these cases in every generator accordingly by prefixing the conflicted names with something which will lead to inconsistency between M3O clients.

asim commented 2 years ago

Do we just move these things to Create following a crud standard? How many cases of New exist?

lambdaR commented 2 years ago

just one for now .... coming form chat service we can use the crud standard or we could just name it ChatNew for example i.e the service name first then the verb ... or any standard that prevent these potential conflicts .

asim commented 2 years ago

OK I've renamed it to Create. Should see the changes everywhere soon. It's at least commited.