rpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 8 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 rpc reads the RPC methods file, gives each method the service the proxyfile's rpc entry maps it to, and writes the RPC table: the routes as JSON, one object per line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Table

func Table(routes []Route) []byte

Table writes the routes, in the order given, as a JSON array with one object per line, so a diff of two tables shows one line for each route that changed. Resolve sorts the routes by path, so the table's order does not depend on the methods file's.

Each string is written by quote.JSON, whose result equals what Jackson's writeValueAsString writes for any text with no control character and no U+2028 or U+2029: Go escapes those two always and writes \u00XX in lower case, Jackson leaves the two as they are and writes upper case. Both write <, > and & as they are.

Types

type Method

type Method struct {
	Service, Method, Action string    // Action is "" when not written
	Reports                 []string  // nil when not written, and when written as []
	Pos                     model.Pos // the entry's mapping
}

Method is one entry of the methods file.

func ReadMethods

func ReadMethods(path string) ([]Method, []model.Problem)

ReadMethods reads the methods file at path, which is JSON read as YAML so that a problem names its line. It returns the problems of the first step that finds any: reading the file, its syntax, then the format check. Every rule of the methods is Resolve's, the two that need no proxyfile included (a report holding a comma, a method listed twice), so one run names the problems of both kinds.

type Route

type Route struct {
	Method
	Target  *model.Service
	Cluster string // Target.Cluster(model.GRPC)
	Name    string // the target's RouteName
}

Route is a method with the service it goes to.

func Resolve

func Resolve(g *model.Gateway, methods []Method) ([]Route, []model.Problem)

Resolve gives each method one target: an exact service name first, else the matching pattern with the longest text, else "*". Ranking exact names first settles the one tie length alone cannot (a.b.C against a.b.*); two different patterns that both match a service never have the same length, so the written order never matters.

g is a gateway read.Proxyfile returned, whose rules have made every target name a declared service with a gRPC port. Resolve returns either the routes, sorted by path, or every problem it finds, sorted.

func (Route) Path

func (r Route) Path() string

Path is the path a gRPC call of the method carries, which its route matches exactly.

Jump to

Keyboard shortcuts

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