app

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	FileTracker   FileTracker
	TokenManager  TokenManager
	UploadTracker UploadTracker

	Logger log.Logger
}

App represents a running application with all the dependant services.

func Start

func Start(cfg *config.Config) (*App, error)

Start initializes the application with the services defined by a given configuration.

func (*App) NewOAuth2Client

func (app *App) NewOAuth2Client(ctx context.Context, oauth2Config oauth2.Config, account string) (*http.Client, error)

NewOAuth2Client returns a http client for the supplied Google account. It will try to get the credentials from the Token Manager, if they are not valid will try to refresh the token or ask for authenticate again.

func (*App) Stop

func (app *App) Stop() error

Stop stops the application releasing all service resources.

type FileTracker

type FileTracker interface {
	CacheAsAlreadyUploaded(filePath string) error
	IsAlreadyUploaded(filePath string) (bool, error)
	RemoveAsAlreadyUploaded(filePath string) error
	Close() error
}

FileTracker represents a service to track file already uploaded.

type TokenManager

type TokenManager interface {
	StoreToken(email string, token *oauth2.Token) error
	RetrieveToken(email string) (*oauth2.Token, error)
	Close() error
}

TokenManager represents a service to keep and read secrets (like passwords, tokens...)

type UploadTracker

type UploadTracker interface {
	Get(fingerprint string) []byte
	Set(fingerprint string, url []byte)
	Delete(fingerprint string)
	Close() error
}

UploadTracker represents a service to keep resumable upload sessions.

Jump to

Keyboard shortcuts

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