Documentation
¶
Overview ¶
Package bodybackend is the body service: a user's scale readings and DEXA scans, the estimates computed from them and the rules for importing readings from a source such as Withings.
It knows nothing about who a user is. The main backend authenticates people and calls this service with a short-lived signed token for one user and one scope (see pkg/shared/bodyapi); the service checks the token and acts on exactly that user's data. It never imports the main backend, the frontend, the workers or anything that signs people in.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Service)
Option changes how New builds a Service.
func WithSpareSecrets ¶
WithSpareSecrets makes the service accept these secrets too, next to the first one, so that the secret can be rotated without downtime: the main backend sends the first line of its file, and the service accepts every line of its own until the old one is removed.
func WithVersion ¶
WithVersion names the running program. It is part of the estimates' ETag, so a new version never answers "not modified" for a result an older algorithm made.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the body service. Use Handler to serve it.
func New ¶
func New(st store.BodyStore, secret string, verifier *bodyapi.Verifier, opts ...Option) (*Service, error)
New returns a Service over a store. secret is the shared secret every call must carry, and verifier holds the public keys of the main backend.
func NewInProcess ¶
NewInProcess runs a body service over st inside this process and returns it with a client for it. The combined `serve` mode uses it, and so does a main backend that has no body service of its own to call. The client talks to the service through the same handler, headers and tokens as a separate process would, with a secret and a signing key made for this run only.
func (*Service) CacheStats ¶
CacheStats reports how often an estimate came from the cache, for tests and diagnostics.
func (*Service) SetVersion ¶
SetVersion names the running program, for services built before it is known (see WithVersion). Call it before the service takes requests.