-
Notifications
You must be signed in to change notification settings - Fork 106
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
feat: Allow the user to set fallback to rest #1203
feat: Allow the user to set fallback to rest #1203
Conversation
This provides a workaround for the connection issue.
@danieljbruce Hey there. Is there a reason this was closed? Currently having to hack around this in my code to support HTTP with the datastore class which isn't ideal. |
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
Need to mock out Gapic and compare constructors
The harness mocks out the constructor and calls reach the constructor as well as the get function. So now we can see what values get passed into the constructor and get function.
Add a working test that makes sure the rest parameter gets passed down to the gapic layer.
Proper describe blocks make it easier for the code to be arranged so that with and without rest tests can be incorporated into the code.
Remove the datastore mock. It is not necessary.
Make a programmatic link to the data type so that the intent is clearer.
Parameterized tests will allow us to delete half the tests. A new type is created for the test parameters.
Explain the purpose of the class. This will make it useful for testing.
This type is only used once so inline it.
Changes to system tests are not necessary. Remove them.
assert resolves to falsy in tests. See if this solves the issue.
Add console logs and assert checks back in.
This should allow the unit tests to pass in the continuous integration environment.
The title of the describe block should match the file. Remove console logs too.
* | ||
*/ | ||
class FakeDatastoreClient extends DatastoreClient { | ||
restParameter: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Dan, just wondering is this "restParameter" expecting a boolean type from Fallback type
too? https://github.com/googleapis/nodejs-datastore/pull/1203/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the type to Fallback
here so that the types line up better.
@@ -1912,6 +1913,7 @@ export interface DatastoreOptions extends GoogleAuthOptions { | |||
apiEndpoint?: string; | |||
sslCreds?: ChannelCredentials; | |||
databaseId?: string; | |||
fallback?: Fallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is already commented somewhere else. Do you think we can provide an example how to initiate client library with fallback
options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a simple system test for this.
This parameter more specifically describes the change.
This system test should show how the rest parameter is being used.
This allows the test to pass with a simple assertion check.
*/ | ||
function compareRequest( | ||
request: DatastoreRequest, | ||
expectedFallback: string | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe here change the type to Fallback to be consistent too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fallback type is more specific . Use it instead.
hey @danieljbruce thanks for this feature, I would like to ask you a couple of things:
|
Change:
Users need to be able to use the rest fallback property. This change allows client library calls to be rest calls instead of grpc calls. They can make this happen by instantiating the client library like so:
new Datastore({namespace, fallback: 'rest'})