Skip to content

cmd-stream/codec-protobuf-go

Repository files navigation

codec-protobuf-go

Go Reference GoReportCard codecov

codec-protobuf-go provides a Protobuf-based codec for cmd-stream-go.

It maps concrete Command and Result types to internal identifiers, allowing type-safe serialization across network boundaries.

Important: This Protobuf codec expects all Command and Result types to implement proto.Message. If a type does not implement proto.Message, the codec will panic at runtime.

How To

import (
  "reflect"
  codec "github.com/cmd-stream/codec-protobuf-go"
)

var (
  // Note: The order of types matters — two codecs created with the same types
  // in a different order are not considered equal.
  cmdTypes = []reflect.Type{
    reflect.TypeFor[*YourCmd](),
    // ...
  }
  resultTypes = []reflect.Type{
    reflect.TypeFor[*YourResult](),
    // ...
  }
  serverCodec = codec.NewServerCodec(cmdTypes, resultTypes)
  clientCodec = codec.NewClientCodec(cmdTypes, resultTypes)
)

About

Protobuf-based codec for cmd-stream-go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages