services

package
v0.0.0-...-5f0c085 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AWSKey      string
	AWSSecret   string
	AWSRegion   string
	AWSBucket   string
	MaxRequests int
	Keys        []string
}

Config holds in-memory service config data.

func (*Config) ValidKey

func (c *Config) ValidKey(key string) bool

ValidKey determines whether the key is part of the set of valid limit override keys.

type Services

type Services struct {
	Config *Config
	Logger *logger.Logger
	Usage  *Usage
}

Services holds shared functionality as independent service functions.

func (*Services) SynthesiseSpeech

func (s *Services) SynthesiseSpeech(text string, voice string) (io.ReadCloser, string, error)

SynthesiseSpeech synthesises speech via AWS Polly.

func (*Services) UploadData

func (s *Services) UploadData(reader io.ReadCloser, contentType string) (string, error)

UploadData uploads data to the configured bucket and returns the location.

type Usage

type Usage struct {
	Started       time.Time
	TotalRequests int
	HourlyUsage   map[string]int
	// contains filtered or unexported fields
}

Usage holds in-memory data about the service usage.

func NewUsage

func NewUsage() *Usage

NewUsage constructs a usage object with initialised values.

func (*Usage) LimitExceeded

func (u *Usage) LimitExceeded(limit int) bool

LimitExceeded returns true if the service has reached its hourly usage limit.

func (*Usage) TrackRequest

func (u *Usage) TrackRequest()

TrackRequest adds an entry to the hourly usage map.

Jump to

Keyboard shortcuts

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