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 ¶
- func AccountGone(ctx context.Context) error
- func Failed(ctx context.Context, err error) error
- func Mount(mux *http.ServeMux, server *connect.Server)
- func NewServer(d Deps, h Handlers) *connect.Server
- func Refuse(ctx context.Context, code connect.Code, cause v1.Cause, ...) error
- func RequireConsent(ctx context.Context, db store.Querier, profileID string) error
- type Caller
- type DB
- type Deps
- type Handlers
- type Rights
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountGone ¶ added in v0.1.5
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
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 ¶
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 ¶
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 ¶
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.
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 ¶
type Handlers struct {
Account apiv1connect.AccountServiceHandler
Attempt apiv1connect.AttemptServiceHandler
Learning apiv1connect.LearningServiceHandler
Module apiv1connect.ModuleServiceHandler
Package apiv1connect.PackageServiceHandler
Progress apiv1connect.ProgressServiceHandler
}
Handlers are the methods of the contract that api serves. A service left unset answers unimplemented; the tests set the one they need.