rpc

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 17 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 is api's server of the contract novatrail.api.v1, on Connect v2 (R17, R18, R33): the methods of the contract, its codecs, and the interceptors every request goes through — its line of the log, its time limit and the checks of architecture 3.1, which run before any handler. The handlers of the methods join it task by task; until then a method answers unimplemented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountGone added in v0.1.5

func AccountGone(ctx context.Context) error

AccountGone is the account marked "deleting" or deleted: the checks give it, and so does a handler that finds the account gone after them (R20).

func Failed added in v0.1.5

func Failed(ctx context.Context, err error) error

Failed is a check or a handler that did not finish — the sign-in service, the database, the rights. The client sees the code alone; the log names the failure by its kind.

func Mount

func Mount(mux *http.ServeMux, server *connect.Server)

Mount puts the server's methods on mux, with the contract's codecs: binary protobuf, and JSON for debugging, written with the protobuf names (R18; contracts README, sections 6 and 9). The JSON codec of Connect discards unknown fields already.

func NewServer

func NewServer(d Deps, h Handlers) *connect.Server

NewServer is the server of the contract, with every method registered and every interceptor in its order: the log's line outermost, so that it sees every refusal, then the time limit, then the checks.

func Refuse

func Refuse(ctx context.Context, code connect.Code, cause v1.Cause, data ...func(*v1.Refusal)) error

Refuse is a refusal of the contract: an error of Connect with its code and the Refusal of its cause as its detail (R17; R97 spec). data, when given, fills the Refusal's data. The message is the cause's name, which holds nothing of the request. The cause goes to the request's line of the log.

func RequireConsent

func RequireConsent(ctx context.Context, db store.Querier, profileID string) error

RequireConsent is step 5 of architecture 3.1, for the handlers of the learning requests (E3): the profile's consent is confirmed, or the request is refused "no consent" (П-1). It runs after the checks, on the profile they let through.

Types

type Caller

type Caller struct {
	// UID is the sign-in service's ID of the token's user.
	UID string
	// AuthTime is when that user signed in.
	AuthTime time.Time
	// AccountID is the account of the UID; empty only on CreateAccount, for a UID
	// with no account yet.
	AccountID string
}

Caller is who a request is from, as the checks found it: the handler reads it with CallerFrom.

func CallerFrom

func CallerFrom(ctx context.Context) (Caller, bool)

CallerFrom is the caller the checks let through, on a method with a token.

type DB

type DB interface {
	store.Querier
	store.Beginner
	store.TxBeginner
}

DB is what the checks read and write the accounts on: the pool of the database api.

type Deps

type Deps struct {
	// Signin is the sign-in service (R32).
	Signin authn.Port
	// DB is the pool of the database api (R29).
	DB DB
	// Rights is api's rights in OpenFGA (R31).
	Rights Rights
	// Log is the service's log.
	Log *slog.Logger
	// RequestTimeout is the longest a request may run (R33).
	RequestTimeout time.Duration
}

Deps is what the server runs on.

type Handlers

Handlers are the methods of the contract that api serves. A service left unset answers unimplemented; the tests set the one they need.

type Rights

type Rights interface {
	Can(ctx context.Context, accountID string, right authz.Right, profileID string) (bool, error)
}

Rights is what the checks ask of the rights: authz.Rights.

Jump to

Keyboard shortcuts

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