-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gRPC API small doc improvements (#152)
- Loading branch information
Pepe Cano
authored
Nov 13, 2020
1 parent
a1d0d61
commit 32d347d
Showing
6 changed files
with
141 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ata/markdown/docs/02 javascript api/09 k6-net-grpc/20 Client/40-Client-close.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: "Client.close()" | ||
--- | ||
|
||
Close the connection to the gRPC service. Tear down all underlying connections. | ||
|
||
### Examples | ||
|
||
<div class="code-group" data-props='{"labels": ["Simple example"], "lineNumbers": [true]}'> | ||
|
||
```javascript | ||
import grpc from "k6/net/grpc"; | ||
|
||
const client = new grpc.Client(); | ||
client.load(['definitions'], 'hello.proto'); | ||
|
||
export default () => { | ||
client.connect("localhost:8080"); | ||
client.close(); | ||
} | ||
``` | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/data/markdown/docs/02 javascript api/09 k6-net-grpc/40-Constants.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: "Constants" | ||
--- | ||
|
||
Define constants to distinguish between [gRPC Response](/javascript-api/k6-net-grpc/response) statuses. | ||
|
||
| Constant | Description | | ||
|----------|-------------| | ||
| `StatusOK` | OK is returned on success. | | ||
| `StatusCanceled` | Canceled indicates the operation was canceled (typically by the caller). | | ||
| `StatusUnknown` | Unknown error. | | ||
| `StatusInvalidArgument` | InvalidArgument indicates the client specified an invalid argument. | | ||
| `StatusDeadlineExceeded` | DeadlineExceeded means operation expired before completion. | | ||
| `StatusNotFound` | NotFound means some requested entity (e.g., file or directory) was not found. | | ||
| `StatusAlreadyExists` | AlreadyExists means an attempt to create an entity failed because one already exists. | | ||
| `StatusPermissionDenied` | PermissionDenied indicates the caller does not have permission to execute the specified operation. | | ||
| `StatusResourceExhausted` | ResourceExhausted indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. | | ||
| `StatusFailedPrecondition` | FailedPrecondition indicates operation was rejected because the system is not in a state required for the operation's execution. | | ||
| `StatusAborted` | Aborted indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc. | | ||
| `StatusOutOfRange` | OutOfRange means operation was attempted past the valid range. E.g., seeking or reading past end of file. | | ||
| `StatusUnimplemented` | Unimplemented indicates operation is not implemented or not supported/enabled in this service. | | ||
| `StatusInternal` | Internal errors. Means some invariants expected by the underlying system have been broken. | | ||
| `StatusUnavailable` | Unavailable indicates the service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations. | | ||
| `StatusDataLoss` | DataLoss indicates unrecoverable data loss or corruption. | | ||
| `StatusUnauthenticated` | Unauthenticated indicates the request does not have valid authentication credentials for the operation. | | ||
|
||
### Example | ||
|
||
<CodeGroup labels={["grpc-test.js"]}> | ||
|
||
```javascript | ||
import grpc from 'k6/net/grpc'; | ||
|
||
const client = new grpc.Client(); | ||
client.load(['definitions'], 'hello.proto'); | ||
|
||
export default () => { | ||
client.connect('grpcb.in:9001', { | ||
// plaintext: false | ||
}); | ||
|
||
const data = { greeting: 'Bert' }; | ||
const response = client.invoke('hello.HelloService/SayHello', data); | ||
|
||
check(response, { | ||
'status is OK': (r) => r && r.status === grpc.StatusOK, | ||
}); | ||
|
||
client.close(); | ||
sleep(1); | ||
}; | ||
``` | ||
|
||
</CodeGroup> |