protobuf

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 11 Imported by: 0

README

xk6-protobuf

A k6 extension for decoding and encoding proto files. Built using xk6.

Setup and Running

Follow these steps to set up and run the K6 benchmark with Protobuf support:

1. Install go

Installing Go toolchain

2. Export the Go PATH

Add the Go binary directory to your system's PATH environment variable:

export PATH=$(go env GOPATH)/bin:$PATH
2. Install xk6

Install the latest version of xk6:

go install go.k6.io/xk6/cmd/xk6@latest
3. Build

Build the K6 binary with the xk6-protobuf extension:

xk6 build --with github.com/ribeirof1/xk6-protobuf@latest

If you want to build it locally, then clone this repository and use:

xk6 build --with xk6-protobuf=.
4. Run

Run the K6 benchmark using the generated binary and the protobuf benchmark file:

./k6 run {proto-benchmark-file}.js

Replace {proto-benchmark-file}.js with the actual file name of your protobuf benchmark script.

Examples

Command to run examples: ./k6 run example/codec.js

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtoFile

type ProtoFile struct {
	// contains filtered or unexported fields
}

func (*ProtoFile) Decode

func (p *ProtoFile) Decode(encodedBytes []byte) (string, error)

Decode protobuf binary format back to JSON

func (*ProtoFile) DecodeDelimited

func (p *ProtoFile) DecodeDelimited(delimitedBytes []byte) (string, error)

Decode a length-prefixed (delimited) protobuf message

func (*ProtoFile) Encode

func (p *ProtoFile) Encode(data string) ([]byte, error)

Encode JSON to protobuf binary format

func (*ProtoFile) EncodeDelimited

func (p *ProtoFile) EncodeDelimited(data string) ([]byte, error)

Encode a protobuf message with a length prefix (Delimited Encoding)

type Protobuf

type Protobuf struct{}

func (*Protobuf) Load

func (p *Protobuf) Load(protoFilePath, lookupType string) (ProtoFile, error)

Load a .proto file and find the requested message type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL