contract

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 20 Imported by: 0 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.

Documentation

Overview

Package contract turns the entities of a workspace into protobuf contracts. It writes the .proto files and their Go code itself, so nobody needs protoc installed.

Index

Constants

View Source
const (
	Timestamp = ".google.protobuf.Timestamp"
	Empty     = ".google.protobuf.Empty"
)
View Source
const (
	CommonPackage  = "common.v1"
	ProblemMessage = ".common.v1.Problem"
	ExistsResponse = ".common.v1.ExistsResponse"

	ContractsDir     = "contracts"
	ContractRegistry = "contracts/codebuild.contracts.json"
)
View Source
const Header = "// Code generated by codebuild. DO NOT EDIT."
View Source
const RegistryVersion = 1

Variables

This section is empty.

Functions

func ProtoName

func ProtoName(goName string) string

Types

type Field

type Field struct {
	Name     string
	GoName   string
	Number   int32
	Type     FieldType
	TypeName string
	Optional bool
	Repeated bool
	Source   *schema.Field
}

type File

type File struct {
	Service  *schema.Service
	Path     string
	Package  string
	GoImport string
	GoName   string
	Imports  []string
	Messages []*Message
	Services []*Service
	// contains filtered or unexported fields
}

func (*File) Message

func (f *File) Message(name string) *Message

func (*File) Proto

func (f *File) Proto() []byte

type Message

type Message struct {
	Name     string
	FullName string
	Fields   []*Field
	Reserved []int32
}

func (*Message) Field

func (m *Message) Field(name string) *Field

type MessageNumbers

type MessageNumbers struct {
	Fields   map[string]int32  `json:"fields"`
	Types    map[string]string `json:"types,omitempty"`
	Reserved []int32           `json:"reserved,omitempty"`
}

type Method

type Method struct {
	Name   string
	Input  string
	Output string
	// Safe marks a call without side effects, which clients may retry.
	Safe bool
}

type Output

type Output struct {
	Path    string
	Content []byte
}

type Registry

type Registry struct {
	Version  int                        `json:"version"`
	Messages map[string]*MessageNumbers `json:"messages"`
	// Renumbered describes the fields that changed type in this build and
	// therefore received a new number.
	Renumbered []string `json:"-"`
}

func NewRegistry

func NewRegistry() *Registry

func UnmarshalRegistry

func UnmarshalRegistry(data []byte) (*Registry, error)

func (*Registry) Marshal

func (r *Registry) Marshal() ([]byte, error)

type RelationRPC

type RelationRPC struct {
	Source *schema.Entity
	Rel    *schema.Relation
	FK     *schema.Field
	List   string
	Link   string
	Unlink string
}

func Relations

func Relations(m *schema.Model, target *schema.Entity) []RelationRPC

type Service

type Service struct {
	Name    string
	Methods []*Method
}

type Set

type Set struct {
	Module string
	Common *File
	Files  []*File
	// contains filtered or unexported fields
}

func Build

func Build(module string, m *schema.Model, registry *Registry) *Set

func (*Set) All

func (s *Set) All() []*File

func (*Set) File

func (s *Set) File(service string) *File

func (*Set) Generate

func (s *Set) Generate() ([]Output, error)

func (*Set) Registry

func (s *Set) Registry() *Registry

func (*Set) SafeMethods added in v0.5.0

func (s *Set) SafeMethods() []string

SafeMethods returns the full names, such as /catalog.v1.ProductService/Get, of every generated call without side effects, sorted.

Jump to

Keyboard shortcuts

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