handler

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CantabularClient

type CantabularClient interface {
	StaticDatasetQueryStreamCSV(ctx context.Context, req cantabular.StaticDatasetQueryRequest, consume cantabular.Consumer) (rowCount int32, err error)
}

CantabularClient contains the required method for the Cantabular Client

type DatasetAPIClient

type DatasetAPIClient interface {
	GetInstance(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, instanceID, ifMatch string) (i dataset.Instance, eTag string, err error)
	PutVersion(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID, edition, version string, v dataset.Version) error
}

DatasetAPIClient contains the required method for the Dataset API Client

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the handler package's error type. Is not meant to be compared as a type, but information should be extracted via the interfaces it implements with callback functions. Is not guaranteed to remain exported so shouldn't be treated as such.

func NewError added in v0.3.0

func NewError(err error, logData map[string]interface{}) *Error

NewError creates a new Error

func (*Error) Error

func (e *Error) Error() string

Error implements the Go standard error interface

func (*Error) LogData

func (e *Error) LogData() map[string]interface{}

LogData implements the DataLogger interface which allows you extract embedded log.Data from an error

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FilterAPIClient added in v1.0.0

type FilterAPIClient interface {
	GetDimensions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID string, q *filter.QueryParams) (dims filter.Dimensions, eTag string, err error)
	GetOutput(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterOutput string) (m filter.Model, err error)
	UpdateFilterOutput(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, filterOutputID string, m *filter.Model) error
}

type FilterInfo added in v1.13.0

type FilterInfo struct {
	DimensionIds   []string
	Filters        []cantabular.Filter
	PopulationType string
	IsPublished    bool
	IsCustom       bool
}

type Generator added in v0.4.0

type Generator interface {
	NewPSK() ([]byte, error)
	Timestamp() time.Time
}

Generator contains methods for dynamically required strings and tokens e.g. UUIDs, PSKs.

type InstanceComplete

type InstanceComplete struct {
	// contains filtered or unexported fields
}

InstanceComplete is the handle for the InstanceCompleteHandler event

func NewInstanceComplete

func NewInstanceComplete(cfg config.Config, c CantabularClient, d DatasetAPIClient, f FilterAPIClient, sPrivate, sPublic S3Client, v VaultClient, p kafka.IProducer, g Generator) *InstanceComplete

NewInstanceComplete creates a new InstanceCompleteHandler

func (*InstanceComplete) GetS3ContentLength added in v0.6.0

func (h *InstanceComplete) GetS3ContentLength(_ context.Context, _ *event.ExportStart, isPublished bool, filename string) (int, error)

GetS3ContentLength obtains an S3 file size (in number of bytes) by calling Head Object

func (*InstanceComplete) Handle

func (h *InstanceComplete) Handle(ctx context.Context, _ int, msg kafka.Message) error

Handle takes a single event.

func (*InstanceComplete) ProduceExportCompleteEvent

func (h *InstanceComplete) ProduceExportCompleteEvent(e *event.ExportStart, rowCount int32, fileName string) error

ProduceExportCompleteEvent sends the final kafka message signifying the export complete

func (*InstanceComplete) UpdateFilterOutput added in v1.0.0

func (h *InstanceComplete) UpdateFilterOutput(ctx context.Context, e *event.ExportStart, size int, isPublished bool, s3Url, filename string) error

func (*InstanceComplete) UpdateInstance

func (h *InstanceComplete) UpdateInstance(ctx context.Context, e *event.ExportStart, size int, isPublished bool, s3Url, filename string) error

UpdateInstance updates the instance downlad CSV link using dataset API PUT /instances/{id} endpoint if the instance is published, then the s3Url will be set as public link and the instance state will be set to published otherwise, a private url will be generated and the state will not be changed

func (*InstanceComplete) UploadCSVFile

func (h *InstanceComplete) UploadCSVFile(ctx context.Context, e *event.ExportStart, req cantabular.StaticDatasetQueryRequest, isPublished, isCustom bool) (string, int32, string, error)

UploadCSVFile queries a static dataset to cantabular using the provided request, transforms the response to a CSV format and streams the data to S3. If the data is published, the S3 file will be stored in the public bucket If the data is private, the S3 file will be stored in the private bucket (encrypted or un-encrypted depending on EncryptionDisabled flag) Returns S3 file URL, file size bytes, number of rows, and any error that happens.

func (*InstanceComplete) ValidateInstance added in v0.3.0

func (h *InstanceComplete) ValidateInstance(i dataset.Instance) (bool, error)

ValidateInstance validates the instance returned from dp-dataset-api Returns isPublished bool value and any validation error

type S3Client

type S3Client interface {
	Head(key string) (*s3.HeadObjectOutput, error)
	UploadWithContext(ctx context.Context, input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
	UploadWithPSK(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error)
	BucketName() string
}

S3Client contains the required method for the S3 Client

type VaultClient added in v0.3.0

type VaultClient interface {
	WriteKey(path, key, value string) error
}

VaultClient contains the required methods for the Vault Client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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