Skip to content
This repository was archived by the owner on Mar 20, 2018. It is now read-only.

Conversation

@evaogbe
Copy link
Contributor

@evaogbe evaogbe commented Oct 24, 2017

To be used in the routing header like this:

self._create_book = api_callable.create_api_call(
            self.library_service_stub.CreateBook,
            settings=defaults['create_book'],
            metadata_overlay=lambda req: {
                b'x-google-request-params':
                    b'name={}&book.read={}'.format(req.name, req.book.read)})

@theacodes
Copy link

Hey @eoogbe, should this be done against api_core instead? (we're about to drop gax)

@evaogbe
Copy link
Contributor Author

evaogbe commented Oct 24, 2017

@jonparrott When you say "about to", how soon do you mean? Routing headers are pretty critical path.

@theacodes
Copy link

@lukesneeringer and @landrito can speak to that.

@theacodes
Copy link

@eoogbe I also thought about this a while and I can't see why we need this. Metadata can already be specified by gapic clients in the generated method.

For example, we could update this generated code:

def create_book(self, name, read=False, ...):
    request = book_pb2.Book(
        name=name,
        read=read,
    )

    return self._create_book(request, ...)

to just this:

def create_book(self, name, read=False, ...):
    request = book_pb2.Book(
        name=name,
        read=read,
    )

    metadata = [
        ('x-google-request-params',
         'name={}&book.read={}'.format(request.name, request.read)),
    ]

    return self._create_book(
        request, metadata=metadata, ...)

Therefore obviating the need for this complex "overlay" logic. Am I missing something?

@evaogbe
Copy link
Contributor Author

evaogbe commented Oct 25, 2017

@jonparrott Fair enough

@evaogbe evaogbe closed this Oct 25, 2017
@theacodes
Copy link

Cool - glad we could figure out a simpler solution. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants