Skip to content

Commit

Permalink
Deprecation of the exerimental grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jan 11, 2024
1 parent d1cd6ba commit d61ea34
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---
title: "grpc"
excerpt: "Experimental GRPC module"
weight: 02
title: 'grpc'
excerpt: 'Experimental GRPC module'
weight: 02
---

# grpc

{{< docs/shared source="k6" lookup="experimental-module.md" version="<K6_VERSION>" >}}
{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

The `k6/experimental/grpc` module is an extension of the [`k6/net/grpc`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-net-grpc). It provides a [gRPC](https://grpc.io/) client for Remote Procedure Calls (RPC) over HTTP/2.

The key-difference between the two modules is new `Stream` class, which provides client and server streaming support. Our long-term goal is to make this module part of k6 core, and long-term to replace the [`k6/net/grpc`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-net-grpc) module.
Prior k6 `v0.49` the key-difference between the two modules was streaming support, but it has been added to the `k6/net/grpc` module as well. We recommend using the `k6/net/grpc` module.

| Class/Method | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 10

# Client

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

`Client` is a gRPC client that can interact with a gRPC server.

| Method | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 40

# Client.close()

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Close the connection to the gRPC service. Tear down all underlying connections.

### Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 20

# Client.connect(address [,params])

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Opens a connection to a gRPC server; will block until a connection is made or a connection error is thrown. Cannot be called during the [`init` phase](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/test-lifecycle).

See [Client.close()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/grpc/client/client-close) to close the connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 30

# Client.invoke(url, request [,params])

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Invokes an unary RPC request to the given method.

The given method to invoke must have its RPC schema previously loaded via the [Client.load()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/grpc/client/client-load) function, otherwise an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 11

# Client.loadProtoset(protosetPath)

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Loads and parses the protoset file (serialized FileDescriptor set) so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.

Must be called within the [`init` phase](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/test-lifecycle).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 10

# Client.load(importPaths, ...protoFiles)

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Loads and parses the protocol buffer descriptors so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.

Must be called within the [`init` phase](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/test-lifecycle).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 40

# Constants

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Define constants to distinguish between [gRPC Response](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/grpc/response) statuses.

| Constant | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 20

# Params

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

_Params_ is an object used by the gRPC methods that generate RPC requests. _Params_ contains request-specific options like headers that should be inserted into the request.

| Name | Type | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 30

# Response

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

| Name | Type | Description |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Response.status` | number | The response gRPC status code. Use the gRPC [status constants](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/grpc/constants) to check equality. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: Stream
excerpt: 'GRPC Streams'
weight: 50
weight: 30
---

# Stream

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Using a GRPC client creates a stream. An important note that the client should be already connected (client.connect called) to the server before creating a stream.

| Method | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 40

# Stream.end()

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Signals to the server that the client has finished sending messages.

### Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 15

# Error

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

The error object is the object that is passed to the `error` event handler function.

| Name | Type | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 10

# Stream.on()

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Set up handler functions for various events on the GRPC stream.

| Parameter | Type | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ weight: 40

# Stream.write()

{{< docs/shared source="k6" lookup="experimental-grpc-module.md" version="<K6_VERSION>" >}}

Writes a message to the stream.

### Example
Expand Down
11 changes: 11 additions & 0 deletions docs/sources/next/shared/experimental-grpc-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Experimental grpc module admonition
---

{{% admonition type="caution" %}}

Staring `k6` version `v0.49` the experimental module `k6/experimental/grpc` has been graduated, and its functionality is available in [the `k6/net/grpc` module](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-net-grpc/). The `k6/experimental/grpc` is deprecated and will be removed in `v0.51.0`.

To migrate your scripts, replace all `k6/experimental/grpc` imports with `k6/net/grpc`.

{{% /admonition %}}

0 comments on commit d61ea34

Please sign in to comment.