github.com/Cloud-Foundations/Dominator@v0.3.4/imagebuilder/logarchiver/api.go (about)

     1  package logarchiver
     2  
     3  import (
     4  	"io"
     5  	"time"
     6  
     7  	"github.com/Cloud-Foundations/Dominator/lib/log"
     8  )
     9  
    10  type BuildInfo struct {
    11  	Duration          time.Duration `json:",omitempty"`
    12  	Error             string        `json:",omitempty"`
    13  	RequestorUsername string        `json:",omitempty"`
    14  }
    15  
    16  type BuildLogArchiver interface {
    17  	AddBuildLog(string, BuildInfo, []byte) error
    18  }
    19  
    20  type BuildLogArchiveOptions struct {
    21  	Quota  uint64
    22  	Topdir string
    23  }
    24  
    25  type BuildLogArchiveParams struct {
    26  	Logger log.DebugLogger
    27  }
    28  
    29  type BuildLogReporter interface {
    30  	GetBuildInfos(incGood, incBad bool) *BuildInfos
    31  	GetBuildInfosForRequestor(username string, incGood, incBad bool) *BuildInfos
    32  	GetBuildInfosForStream(streamName string, incGood, incBad bool) *BuildInfos
    33  	GetBuildLog(imageName string) (io.ReadCloser, error)
    34  	GetSummary() *Summary
    35  }
    36  
    37  type BuildLogger interface {
    38  	BuildLogArchiver
    39  	BuildLogReporter
    40  }
    41  
    42  type BuildInfos struct {
    43  	Builds      map[string]BuildInfo // Key: image name.
    44  	ImagesByAge []string             // May be empty.
    45  }
    46  
    47  type RequestorSummary struct {
    48  	NumBuilds      uint64
    49  	NumGoodBuilds  uint64
    50  	NumErrorBuilds uint64
    51  }
    52  
    53  type StreamSummary struct {
    54  	NumBuilds      uint64
    55  	NumGoodBuilds  uint64
    56  	NumErrorBuilds uint64
    57  }
    58  
    59  type Summary struct {
    60  	Requestors map[string]*RequestorSummary // Key: username.
    61  	Streams    map[string]*StreamSummary    // Key: stream name.
    62  }
    63  
    64  func New(options BuildLogArchiveOptions,
    65  	params BuildLogArchiveParams) (BuildLogger, error) {
    66  	return newBuildLogArchive(options, params)
    67  }
    68  
    69  func NewNullLogger() BuildLogArchiver {
    70  	return newNullLogger()
    71  }