Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/javascript-api/k6-net-grpc/stream/stream-write.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/javascript-api/k6-net-grpc/stream/stream-write/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Stream.write()
Writes a message to the stream. The message is a canonical request object, as-per the Protobuf JSON Mapping.
Example
import { Client, Stream } from 'k6/net/grpc';
import { sleep } from 'k6';
const client = new Client();
client.load([], '../../grpc_server/route_guide.proto');
export default () => {
if (__ITER == 0) {
client.connect('127.0.0.1:10000', { plaintext: true });
}
const stream = new Stream(client, 'main.RouteGuide/RecordRoute');
stream.on('data', (stats) => {
console.log('Finished trip with', stats.pointCount, 'points');
});
// send an item
stream.write({ latitude: 406109563, longitude: -742186778 });
// send end-signal to the server
stream.end();
sleep(1);
};Was this page helpful?
Related resources from Grafana Labs

