report

package
v3.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package report build a text with all actions performed by the tool. As the tool can work in background, it is useful to periodically retrieve a report with all actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(r Report)

Add stores the report information to be retrieved later.

func Build

func Build(f Format) (string, error)

Build generates the report in the specify format. Every time this function is called the internal cache of reports is cleared. On error it will return an Error type encapsulated in a traceable error. To retrieve the desired error you can do:

type causer interface {
  Cause() error
}

if causeErr, ok := err.(causer); ok {
  switch specificErr := causeErr.Cause().(type) {
  case *report.Error:
    // handle specifically
  default:
    // unknown error
  }
}

func Clear

func Clear()

Clear removes all reports from the internal cache. Useful for testing environments.

func ErrorEqual

func ErrorEqual(first, second error) bool

ErrorEqual compares two Error objects. This is useful to compare down to the low level errors.

Types

type Error

type Error struct {
	Code ErrorCode
	Err  error
}

Error stores error details from a problem occurred while reading a report file or parsing the environment variables.

func (Error) Error

func (e Error) Error() string

Error returns the error in a human readable format.

func (Error) String

func (e Error) String() string

String translate the error to a human readable text.

type ErrorCode

type ErrorCode string

ErrorCode stores the error type that occurred while reading report parameters.

const (
	// ErrorCodeTemplate error parsing template.
	ErrorCodeTemplate ErrorCode = "template"
)

func (ErrorCode) String

func (e ErrorCode) String() string

String translate the error code to a human readable text.

type Format

type Format string

Format defines the format used in the e-mail content.

const (
	// FormatPlain send e-mail containing only ascii characters.
	FormatPlain Format = "plain"

	// FormatHTML send e-mail with a HTML structure for better presentation
	// of the content.
	FormatHTML Format = "html"
)

func (Format) String

func (f Format) String() string

String gives the string representation that can be used in e-mail headers.

type ListBackups

type ListBackups struct {
	Durations struct {
		List time.Duration
	}
	// contains filtered or unexported fields
}

ListBackups stores statistics and errors when the remote backups information are retrieved.

func NewListBackups

func NewListBackups() ListBackups

NewListBackups initialize a new report item to retrieve the remote backups.

func (ListBackups) Build

func (l ListBackups) Build(f Format) (string, error)

Build creates a report with details of a remote backups listing. On error it will return an Error type encapsulated in a traceable error. To retrieve the desired error you can do:

type causer interface {
  Cause() error
}

if causeErr, ok := err.(causer); ok {
  switch specificErr := causeErr.Cause().(type) {
  case *report.Error:
    // handle specifically
  default:
    // unknown error
  }
}

type RemoveOldBackups

type RemoveOldBackups struct {
	Backups   []cloud.Backup
	Durations struct {
		List   time.Duration
		Remove time.Duration
	}
	// contains filtered or unexported fields
}

RemoveOldBackups stores useful information about the removed backups, including performance issues.

func NewRemoveOldBackups

func NewRemoveOldBackups() RemoveOldBackups

NewRemoveOldBackups initialize a new report item for removing the old backups.

func (RemoveOldBackups) Build

func (r RemoveOldBackups) Build(f Format) (string, error)

Build creates a report with details of old backups removal procedure. On error it will return an Error type encapsulated in a traceable error. To retrieve the desired error you can do:

type causer interface {
  Cause() error
}

if causeErr, ok := err.(causer); ok {
  switch specificErr := causeErr.Cause().(type) {
  case *report.Error:
    // handle specifically
  default:
    // unknown error
  }
}

type Report

type Report interface {
	Build(Format) (string, error)
}

Report is the contract that every report must respect so it can be included in the notification engine.

type SendBackup

type SendBackup struct {
	Backup    cloud.Backup
	Paths     []string
	Durations struct {
		Build   time.Duration
		Encrypt time.Duration
		Send    time.Duration
	}
	// contains filtered or unexported fields
}

SendBackup stores all useful information of an uploaded backup. It includes performance data for system improvements.

func NewSendBackup

func NewSendBackup() SendBackup

NewSendBackup initialize a new report item for the backup upload action.

func (SendBackup) Build

func (s SendBackup) Build(f Format) (string, error)

Build creates a report with details of an uploaded backup to the cloud. On error it will return an Error type encapsulated in a traceable error. To retrieve the desired error you can do:

type causer interface {
  Cause() error
}

if causeErr, ok := err.(causer); ok {
  switch specificErr := causeErr.Cause().(type) {
  case *report.Error:
    // handle specifically
  default:
    // unknown error
  }
}

type Test

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

Test is a simple test report only to check if everything is working well.

func NewTest

func NewTest() Test

NewTest initialize a new test report to verify the notification mechanisms.

func (Test) Build

func (tr Test) Build(f Format) (string, error)

Build creates a report for testing purpose. On error it will return an Error type encapsulated in a traceable error. To retrieve the desired error you can do:

type causer interface {
  Cause() error
}

if causeErr, ok := err.(causer); ok {
  switch specificErr := causeErr.Cause().(type) {
  case *report.Error:
    // handle specifically
  default:
    // unknown error
  }
}

Jump to

Keyboard shortcuts

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