Coder Social home page Coder Social logo

googleapis / gapic-generator-cpp Goto Github PK

View Code? Open in Web Editor NEW
13.0 42.0 10.0 214 KB

Generate C++ API client libraries from Protocol Buffers.

License: Apache License 2.0

Python 6.55% C++ 79.13% Shell 3.51% Awk 1.13% CMake 7.45% Dockerfile 2.23%
protobuf c-plus-plus code-generation gapic

gapic-generator-cpp's Introduction

API Client Generator for C++

release level

A generator and runtime for protocol buffer described APIs for and in C++.

This repository contains two subprojects:

  • An API client library generator, implemented as a protoc plugin
  • A runtime library supporting the generated code (known as gax)

The generator takes APIs specified by protocol buffers, such as those inside Google, and generates a client library.

Note: this project has been shelved. See STATUS.md for the current status of various features and designs.

Versioning

This library follows Semantic Versioning. Please note it is currently under active development. Any release versioned 0.x.y is subject to backwards-incompatible changes at any time.

GA: Libraries defined at a GA quality level are expected to be stable and all updates in the libraries are guaranteed to be backwards-compatible. Any backwards-incompatible changes will lead to the major version increment (1.x.y -> 2.0.0).

Beta: Libraries defined at a Beta quality level are expected to be mostly stable and we're working towards their release candidate. We will address issues and requests with a higher priority.

Alpha: Libraries defined at an Alpha quality level are still a work-in-progress and are more likely to get backwards-incompatible updates. Additionally, it's possible for Alpha libraries to get deprecated and deleted before ever being promoted to Beta or GA.

Contributing changes

See CONTRIBUTING.md for details on how to contribute to this project, including how to build and test your changes as well as how to properly format your code.

Licensing

Apache 2.0; see LICENSE for details.

gapic-generator-cpp's People

Contributors

michaelbausor avatar software-dov avatar vam-google avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gapic-generator-cpp's Issues

Generate gax::Operation returning client methods

Instead of returning raw google::longrunning::Operation and forcing the user to conduct their own typechecking and deserialization, generated clients will provide methods that return gax::Operation. The concrete types are deduced from API proto annotations.

Add OperationsStub abstract class

The OperationsStub is a gax owned abstract class that defines methods GetOperation, DeleteOperation, and CancelOperation that are used as part of the LRO method workflow; in particular, GetOperation takes a name referring to an in-flight operation and returns a new operation with the same name. The new operation may have new metadata and may have finished successfully or represent an error.

Add PollingPolicy

PollingPolicy is an interface primitive used to implement the generic Operation polling loop.

Implement LRO poll loop

As part of the future returning LRO client method implementation, provide a generic polling loop that takes a gax::Operation, a polling policy, and an optional metadata handler function and returns a StatusOr that contains either a response object or a failure status.

Implementing this feature depends on #23 and #27

Add tests, impl, and use gax::IdempotencyPolicy

Method idempotency is important when determining whether it is safe to retry a failed operation. IdempotencyPolicy will be an abstract base class and will expose one interface method, CanRetry, and a Clone method, similar to RetryPolicy and BackoffPolicy.

The proposed method signature is:

bool CanRetry(gax::Status const& status, gax::MethodInfo const& info) const;

The reference concrete child class will take a conservative approach to retryability.

Design, implementation, and use of Idempotency

The idempotency of non-GET based API calls is application specific, and advanced users may want to further customize idempotency.

This issue tracks the design of a per-client idempotency policy type, its generation in the generated client code, and its use in the client retry loop for synchronous, unary rpcs.

All local includes in user-visible gax headers use the gax/ path

To prevent collision with user owned headers with similar names, all gax headers that reference other gax headers should use the gax path in the include.

E.g.

// StatusOr header, status_or.h
#include "status.h"

becomes

// StatusOr header, status_or.h
#include "gax/status.h"

Request fails with DEADLINE_EXCEEDED

I have created an example using the vision API here: https://github.com/michaelbausor/gapic-generator-cpp/tree/examples/examples/vision

I would expect the example to succeed - instead it fails with DEADLINE_EXCEEDED.

Steps to reproduce:

Note that you will need to have the GOOGLE_APPLICATION_CREDENTIALS environment variable set.

Enable master branch protection

      This repository does not seem to have master branch
      protection enabled, at least in the way I'm expecting.
      I was hoping for:

      - master branch protection
      - requiring at least one code reviewer
      - requiring at least two status checks
      - enforcing rules for admins

      Please turn it on!

Implement gax::CallContext

CallContext provides a programmable wrapper that hides grpc::ClientContext. It is used for setting rpc deadlines, setting idempotency, adding application specific metadata, and setting other options.

Make an OperationDeadlinePolicy interface

Setting the per-rpc deadline is sufficiently orthogonal to the purview of the RetryPolicy to merit a separate interface. Something like

class OperationDeadlinePolicy {
 public:
  virtual std::unique_ptr<OperationDeadlinePolicy> clone() const = 0;
  virtual std::chrono::system_clock::time_point Deadline() = 0;
};

template<typename Clock = DefaultClock>
class DefaultOperationDeadlinePolicy : public OperationDeadlinePolicy {
 public:
  template<typename Rep = int64_t, Period = std::milli>
  DefaultOperationDeadlinePolicy(std::chrono::duration<Rep, Period> rpc_duration,
                                                      Clock c = Clock{}) : 
                           duration_(std::chrono::duration_cast<std::chrono::milliseconds>(rpc_duration)), 
                           c_(std::move(c)) {}

  std::chrono::system_clock::time_point Deadline() override {
    return c_.now() + duration_;
  }

 private:
  std::chrono::milliseconds const duration_;
  Clock c_;
};

Add generated types for each LRO response

For each LRO rpc e.g.

rpc GetBigFoo(GetBigFooRequest) returns (google.longrunning.Operation)

generate a using statement for the gax::Operation response in the client and use it in the generated method. E.g.:

using GetBigFooOperation = gax::Operation<Foo, FooMeta>;

This turns this code:

gax::StatusOr<gax::Operation<Foo, FooMeta>> res = client.GetBigFoo(getBigFooRequest);
if (res) {
  gax::Operation<Foo, FooMeta> op = *std::move(res);
}

into this:

gax::StatusOr<GetBigFooOperation> res = client.GetBigFoo(getBigFooRequest);
if (res) {
  GetBigFooOperation op = *std::move(res);
}

This is not only a saving of characters typed, but also ties together the two parameters (result and metadata type) into a single type that describes a particular operation. These parameters and not mix-and-matchable, so it makes sense to treat each possible LRO response as a unit.

Implementation of gax::Operation class

The backbone of LRO methods is gax::Operation. It is responsible for providing type-safe wrappers around google.longrunning.Operation.

Implementing this feature depends on #28

Remove java and go dependencies in WORKSPACE file

In order to build the operations proto library (provided by the com_google_googleapis repository) and generate a corresponding C++ library (currently provided by gax) the WORKSPACE file needs to load and set up the java and go repositories from com_google_googleapis. This is a hack and adds unnecessary dependencies.

Tracking bug to remove the hack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.