Documentation ¶
Overview ¶
Package model is a model abstraction of publish.
Index ¶
- Variables
- func ApplyTransmissionRiskOverrides(p *verifyapi.Publish, overrides verifyapi.TransmissionRiskVector)
- func DaysFromSymptomOnset(onsetInterval int32, checkInterval int32) int32
- func IntervalNumber(t time.Time) int32
- func ReportTypeTransmissionRisk(reportType string, providedTR int) int
- func TimeForIntervalNumber(interval int32) time.Time
- func TruncateWindow(t time.Time, d time.Duration) time.Time
- type Exposure
- func (e *Exposure) AddMissingRegions(regions []string)
- func (e *Exposure) ExposureKeyBase64() string
- func (e *Exposure) HasBeenRevised() bool
- func (e *Exposure) HasDaysSinceSymptomOnset() bool
- func (e *Exposure) HasHealthAuthorityID() bool
- func (e *Exposure) Revise(in *Exposure) (bool, error)
- func (e *Exposure) SetDaysSinceSymptomOnset(d int32)
- func (e *Exposure) SetHealthAuthorityID(haID int64)
- func (e *Exposure) SetRevisedAt(t time.Time) error
- func (e *Exposure) SetRevisedDaysSinceSymptomOnset(d int32)
- func (e *Exposure) SetRevisedReportType(rt string)
- func (e *Exposure) SetRevisedTransmissionRisk(tr int)
- type KeyTransform
- type Transformer
- type TransformerConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorExposureKeyMismatch - internal coding error, tried to revise key A by passing in key B ErrorExposureKeyMismatch = fmt.Errorf("attempted to revise a key with a different key") // ErrorNonLocalProvenance - key revesion attempted on federated key, which is not allowed ErrorNonLocalProvenance = fmt.Errorf("key not origionally uploaded to this server, cannot revise") // ErrorKeyAlreadyRevised - attempt to revise a key that has already been revised. ErrorKeyAlreadyRevised = fmt.Errorf("key has already been revised and cannot be revised again") )
Functions ¶
func ApplyTransmissionRiskOverrides ¶
func ApplyTransmissionRiskOverrides(p *verifyapi.Publish, overrides verifyapi.TransmissionRiskVector)
ApplyTransmissionRiskOverrides modifies the transmission risk values in the publish request based on the provided TransmissionRiskVector. In the live system, the TransmissionRiskVector values come from a trusted public health authority and are embedded in the verification certificate (JWT) transmitted on the publish request.
func DaysFromSymptomOnset ¶
DaysFromSymptomOnset calculates the number of days between two start intervals. Partial days are rounded up/down to the closest day. If the checkInterval is before the onsetInterval, number of days will be negative.
func IntervalNumber ¶
IntervalNumber calculates the exposure notification system interval number based on the input time.
func TimeForIntervalNumber ¶
TimeForIntervalNumber returns the time at which a specific interval starts. The interval number * 600 (10m = 600s) is the corresponding unix timestamp.
Types ¶
type Exposure ¶
type Exposure struct { ExposureKey []byte TransmissionRisk int AppPackageName string Regions []string IntervalNumber int32 IntervalCount int32 CreatedAt time.Time LocalProvenance bool FederationSyncID int64 // These fileds are nullable to maintain backwards compatibility with // older versions that predate their existence. HealthAuthorityID *int64 ReportType string DaysSinceSymptomOnset *int32 // Fields to support key revision. RevisedReportType *string RevisedAt *time.Time RevisedDaysSinceSymptomOnset *int32 RevisedTransmissionRisk *int // contains filtered or unexported fields }
Exposure represents the record as stored in the database
func ReviseKeys ¶
func ReviseKeys(ctx context.Context, existing map[string]*Exposure, incoming []*Exposure) ([]*Exposure, error)
ReviseKeys takes a set of existing keys, and a list of keys currently being uploaded. Only keys that need to be revsised or are being created fir the first time are returned in the output set.
func TransformExposureKey ¶
func TransformExposureKey(exposureKey verifyapi.ExposureKey, appPackageName string, upcaseRegions []string, settings *KeyTransform) (*Exposure, error)
TransformExposureKey converts individual key data to an exposure entity. Validations during the transform include:
* exposure keys are exactly 16 bytes in length after base64 decoding * minInterval <= interval number <= maxInterval * MinIntervalCount <= interval count <= MaxIntervalCount
func (*Exposure) AddMissingRegions ¶
func (*Exposure) ExposureKeyBase64 ¶
ExposureKeyBase64 returns the ExposuerKey property base64 encoded.
func (*Exposure) HasBeenRevised ¶
func (*Exposure) HasDaysSinceSymptomOnset ¶
HasDaysSinceSymptomOnset returns true if the this key has the days since symptom onset field is et.
func (*Exposure) HasHealthAuthorityID ¶
func (*Exposure) SetDaysSinceSymptomOnset ¶
SetDaysSinceSymptomOnset sets the days since sympton onset field, possibly allocating a new pointer.
func (*Exposure) SetHealthAuthorityID ¶
func (*Exposure) SetRevisedDaysSinceSymptomOnset ¶
func (*Exposure) SetRevisedReportType ¶
func (*Exposure) SetRevisedTransmissionRisk ¶
type KeyTransform ¶
type KeyTransform struct { MinStartInterval int32 MaxStartInterval int32 MaxEndInteral int32 CreatedAt time.Time ReleaseStillValidKeys bool BatchWindow time.Duration }
KeyTransform represents the settings to apply when transforming an individual key on a publish request.
type Transformer ¶
type Transformer struct {
// contains filtered or unexported fields
}
Transformer represents a configured Publish -> Exposure[] transformer.
func NewTransformer ¶
func NewTransformer(config TransformerConfig) (*Transformer, error)
NewTransformer creates a transformer for turning publish API requests into records for insertion into the database. On the call to TransformPublish all data is validated according to the transformer that is used.
func (*Transformer) TransformPublish ¶
func (t *Transformer) TransformPublish(ctx context.Context, inData *verifyapi.Publish, claims *verification.VerifiedClaims, batchTime time.Time) ([]*Exposure, error)
TransformPublish converts incoming key data to a list of exposure entities. The data in the request is validated during the transform, including:
* 0 exposure Keys in the requests * > Transformer.maxExposureKeys in the request