services

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Services used by API endpoint handlers and other bits of code. This is a collection of common things needed by code, such as:

  • Access to an instance of logger
  • AWS S3 API
  • The current Mongo DB connection
  • Facilities to send user notifications
  • API configuration

among others

Index

Constants

This section is empty.

Variables

View Source
var ApiVersion string

NOTE: these 2 vars are set during compilation in gitlab CI build (see Makefile)

View Source
var GitHash string

Functions

This section is empty.

Types

type APIServices

type APIServices struct {
	// Configuration read in on startup
	Config config.APIConfig

	// Default logger
	Log logger.ILogger

	// This is configured on startup to talk to the configured AWSCloudwatchRegion
	AWSSessionCW *session.Session

	// Anything talking to S3 should use this
	S3 s3iface.S3API

	SNS awsutil.SNSInterface

	// Anything accessing files should use this
	FS fileaccess.FileAccess

	// Validation of JWT tokens
	JWTReader IJWTReader

	// ID generator
	IDGen IDGenerator

	// URL signer for S3
	Signer URLSigner

	// Zip File Generator
	Exporter ExportZipper

	// Notification Handler
	Notifications notifications.NotificationManager

	// Timestamp retriever - so can be mocked for unit tests
	TimeStamper timestamper.ITimeStamper

	// Our mongo db connection
	Mongo *mongo.Client

	// "User DB"
	Users pixlUser.UserDetailsLookup

	// "Expression DB"
	Expressions expressionStorage.ExpressionDB
}

APIServices contains any services that HTTP handlers would want to use, like logging/config reading

func InitAPIServices

func InitAPIServices(cfg config.APIConfig, jwtReader IJWTReader, idGen IDGenerator, signer URLSigner, exporter ExportZipper) APIServices

InitAPIServices sets up a new APIServices instance

type ExportZipper

type ExportZipper interface {
	MakeExportFilesZip(*APIServices, string, string, string, string, string, []string, []string) ([]byte, error)
}

ExportZipper - Interface for creating an export zip file

type IDGenerator

type IDGenerator interface {
	GenObjectID() string
}

IDGenerator - Generates ID strings

type IJWTReader

type IJWTReader interface {
	GetUserInfo(*http.Request) (pixlUser.UserInfo, error)
}

IJWTReader - User ID getter from HTTP request

type MockIDGenerator

type MockIDGenerator struct {
	IDs []string
}

Here we really just expose some test helpers

func (*MockIDGenerator) GenObjectID

func (m *MockIDGenerator) GenObjectID() string

type URLSigner

type URLSigner interface {
	GetSignedURL(s3iface.S3API, string, string, time.Duration) (string, error)
}

URLSigner - Generates AWS S3 signed URLs

Jump to

Keyboard shortcuts

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