Skip to content

Commit 63c6c4b

Browse files
authored
Update k6/ws blockquote to refer the experimental module (#1226)
1 parent 034b0e9 commit 63c6c4b

File tree

14 files changed

+51
-8
lines changed

14 files changed

+51
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import WsBlockquote from './ws-blockquote.view';
2+
3+
export default WsBlockquote;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Blockquote from 'components/shared/blockquote';
2+
import React from 'react';
3+
4+
const WsBlockquote = () => (
5+
<Blockquote mod="info">
6+
<h4>A module with a better and standard API exists</h4>
7+
<p>
8+
The new{' '}
9+
<a href="https://k6.io/docs/javascript-api/k6-experimental/websockets/">
10+
k6/experimental/websockets API
11+
</a>{' '}
12+
partially implements the{' '}
13+
<a href="https://websockets.spec.whatwg.org/">
14+
WebSockets API living standard
15+
</a>
16+
.
17+
</p>
18+
<p>
19+
When possible, we recommend using the new API. It uses a global event loop
20+
for consistency with other k6 APIs and better performance.
21+
</p>
22+
</Blockquote>
23+
);
24+
25+
export default WsBlockquote;

src/components/templates/doc-page/doc-page-content/doc-page-content.view.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Link } from 'components/shared/link';
1818
import TableWithNestedRows from 'components/shared/table-with-nested-rows';
1919
import TableWrapper from 'components/shared/table-wrapper';
2020
import Tooltip, { BNIT, BWIPT } from 'components/shared/tooltip';
21+
import WsBlockquote from 'components/shared/ws-blockquote';
2122
import React, { useRef } from 'react';
2223

2324
import styles from './doc-page-content.module.scss';
@@ -41,6 +42,7 @@ const componentsForNativeReplacement = {
4142
BrowserWIP,
4243
ExperimentalBlockquote,
4344
BlockingAwsBlockquote,
45+
WsBlockquote,
4446
InstallationInstructions,
4547
Tooltip,
4648
BNIT,

src/data/markdown/docs/02 javascript api/12 k6-ws.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22
title: "k6/ws"
33
excerpt: "k6 WebSocket API"
44
---
5+
<WsBlockquote />
56

6-
<Blockquote mod='info'>
7-
8-
#### An extension with much better and standard API exists
9-
10-
[xk6-websockets](https://github.com/grafana/xk6-websockets) implements [the WebSockets API living standard](https://websockets.spec.whatwg.org/). While the implementation isn't full, it uses a global event loop instead of local one.
11-
12-
Currently, it's available as an experimental module [`k6/experimental/websockets`](/javascript-api/k6-experimental/websockets/). It is also likely that it will at some point become part of the core of k6.
13-
</Blockquote>
147

158
The ws module provides a [WebSocket](https://en.wikipedia.org/wiki/WebSocket) client implementing the [WebSocket protocol](http://www.rfc-editor.org/rfc/rfc6455.txt).
169

src/data/markdown/docs/02 javascript api/12 k6-ws/10-connect- url- params- callback -.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: 'Create a WebSocket connection, and provides a Socket client to int
44
excerpt: 'Create a WebSocket connection, and provides a Socket client to interact with the service.'
55
---
66

7+
<WsBlockquote />
8+
79
Initiate a WebSocket connection to a remote host.
810

911
Calling connect will block the VU finalization until the WebSocket connection is closed. Instead of continuously looping the main function (`export default function() { ... }`) over an over, each VU will be halted listening to async events and executing their event handlers until the connection is closed.

src/data/markdown/docs/02 javascript api/12 k6-ws/20-Params.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: 'Used for setting various WebSocket request-specific parameters suc
44
excerpt: 'Used for setting various WebSocket request-specific parameters such as headers, tags, etc.'
55
---
66

7+
<WsBlockquote />
8+
79
_Params_ is an object used by the WebSocket methods that generate WebSocket requests. _Params_ contains request-specific options like headers that should be inserted into the request.
810

911
| Name | Type | Description |

src/data/markdown/docs/02 javascript api/12 k6-ws/80 Socket.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: 'Socket'
33
excerpt: 'Socket is a WebSocket client to interact with a WebSocket connection.'
44
---
55

6+
<WsBlockquote />
7+
68
`Socket` is a WebSocket client to interact with a WebSocket connection. You can use it to listen various events happening on the WebSocket connection and send messages to the server. Additionally, you can use socket.setTimeout() and socket.setInterval() to execute code in the background, or repeatedly, while the WebSocket connection is open.
79

810
| Method | Description |

src/data/markdown/docs/02 javascript api/12 k6-ws/80 Socket/Socket-close--.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: 'Socket.close([code])'
33
excerpt: 'Close the WebSocket connection.'
44
---
55

6+
<WsBlockquote />
7+
68
Close the WebSocket connection.
79

810
| Parameter | Type | Description |

src/data/markdown/docs/02 javascript api/12 k6-ws/80 Socket/Socket-on-event- callback-.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: 'Socket.on(event, callback)'
33
excerpt: 'Set up callback functions for various events on the WebSocket connection.'
44
---
55

6+
<WsBlockquote />
7+
68
Set up callback functions for various events on the WebSocket connection. Multiple handlers can be defined for the same event.
79

810
| Parameter | Type | Description |

src/data/markdown/docs/02 javascript api/12 k6-ws/80 Socket/Socket-ping--.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: 'Socket.ping()'
33
excerpt: 'Send a ping. Ping messages can be used to verify that the remote endpoint is responsive.'
44
---
55

6+
<WsBlockquote />
7+
68
Send a ping. Ping messages can be used to verify that the remote endpoint is responsive.
79

810
### Example

0 commit comments

Comments
 (0)