protobuffer

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

xk6-protobuffer

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/cnsvr/xk6-protobuffer@latest

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

xk6 build --with xk6-protobuffer=.
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.js

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtoBuffer

type ProtoBuffer struct {
	Compiler *protocompile.Compiler
	Messages map[string]*ProtoMessage
}

func NewProtoBuffer

func NewProtoBuffer() *ProtoBuffer

func (*ProtoBuffer) Get added in v1.4.0

func (p *ProtoBuffer) Get(messageType string) (*ProtoMessage, error)

func (*ProtoBuffer) Load

func (p *ProtoBuffer) Load(protoFilePath, messageType string) (*ProtoMessage, error)

func (*ProtoBuffer) LoadFromFolder added in v1.4.0

func (p *ProtoBuffer) LoadFromFolder(folderPath string) error

func (*ProtoBuffer) LoadProtoFile added in v1.4.0

func (p *ProtoBuffer) LoadProtoFile(protoFilePath string) error

type ProtoMessage

type ProtoMessage struct {
	MessageDesc protoreflect.MessageDescriptor
	Message     *dynamicpb.Message
}

func (*ProtoMessage) Decode

func (pm *ProtoMessage) Decode(protoData []byte) error

func (*ProtoMessage) Encode

func (pm *ProtoMessage) Encode() ([]byte, error)

func (*ProtoMessage) GetField

func (pm *ProtoMessage) GetField(field string) (interface{}, error)

func (*ProtoMessage) SetField

func (pm *ProtoMessage) SetField(field string, value interface{}) error

Jump to

Keyboard shortcuts

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