Schema Registry Type Enum (sr/enums.go)

franz-go · pkg/sr/enums.go · go · BSD-3-Clause
integration, infra, database, lang:go, tag:enum, tag:serialization

Defines supported schema types (Avro, Protobuf, JSON) for Kafka Schema Registry interactions. Use this to enforce type safety when serializing or deserializing schema definitions.

// Source: https://github.com/twmb/franz-go | License: BSD-3-Clause | Copyright 2020, Travis Bischel
// Provided via justclaw.it.com; keep this notice with the code.
package sr

import (
	"fmt"
	"strings"
)

// SchemaType as an enum representing schema types. The default schema type
// is avro.
type SchemaType int

const (
	TypeAvro SchemaType = iota
	TypeProtobuf
	TypeJSON
)

func (t SchemaType) String() string {
	switch t {
	case TypeAvro:
		return "AVRO"
	case TypeProtobuf:
		return "PROTOBUF"
	case TypeJSON:
		return "JSON"
	default:
		return ""
	}
}

func (t SchemaType) MarshalText() ([]byte, error) {
	s := t.String()
	if s == "" {
		return nil, fmt.Errorf("unknown schema type %d", t)
	}
	return []byte(s), nil
}

func (t *SchemaType) UnmarshalText(text []byte) error {
	switch s := str

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key