codec

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package codec provides the Transcodely JSON wire codec.

This file is a verbatim copy of github.com/transcodely/api/internal/connect/codec.go at commit eca70c69a494b2d9cc75b79aea5580324a99a77b. Do NOT edit here — edit upstream in the api repo and resync. CI verifies the two files match.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtoJSONCodec

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

ProtoJSONCodec is a JSON codec that uses snake_case field names and simplified lowercase enum values. This provides a REST-like JSON format matching our database conventions.

Example transformations:

  • field names: "basePath" → "base_path"
  • enums: "JOB_STATUS_PENDING" → "pending"
  • enums: "ORIGIN_PROVIDER_GCS" → "gcs"

The codec uses proto reflection to automatically handle all enums, including future additions, without any hardcoded mappings.

func NewProtoJSONCodec

func NewProtoJSONCodec() *ProtoJSONCodec

NewProtoJSONCodec creates a new JSON codec with snake_case field names and simplified enum values.

func (*ProtoJSONCodec) Marshal

func (c *ProtoJSONCodec) Marshal(msg any) ([]byte, error)

Marshal serializes a protobuf message to JSON with snake_case field names and simplified enum values.

func (*ProtoJSONCodec) Name

func (c *ProtoJSONCodec) Name() string

Name returns the codec name.

func (*ProtoJSONCodec) Unmarshal

func (c *ProtoJSONCodec) Unmarshal(data []byte, msg any) error

Unmarshal deserializes JSON into a protobuf message. Accepts both simplified enum values (e.g., "pending") and full names (e.g., "JOB_STATUS_PENDING").

Jump to

Keyboard shortcuts

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