cbpatch

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	StorageBucketName string
	RelativeFilePath  string
	RemoteFilePath    string
	Dir               string
	Number            int
	FileName          string
	File              *os.File
	ZippedFileName    string
	ZippedFile        *os.File
	IsChanged         bool
	IsDeleted         bool
	ZippedHash        string
	UnzippedHash      string
	PatchCount        int
	Validation        func(line []string, bucket *Bucket) error
	Patches           []Patch
	ErrorHandler      ErrorHandler
	Logger            Logger
	Storage           Storage
}

func NewBucket

func NewBucket(
	errorHandler ErrorHandler,
	logger Logger,
	storage Storage,
	storageBucketName,
	relativeFilePath,
	remoteFilePath,
	dir string,
	number int,
	zippedHash,
	unzippedHash string,
	patchCount int,
	validation func(line []string, bucket *Bucket) error,
) *Bucket

func (*Bucket) AddPatch

func (b *Bucket) AddPatch(patch Patch) error

func (*Bucket) Compress

func (b *Bucket) Compress() error

func (*Bucket) Download

func (b *Bucket) Download() error

func (*Bucket) Hash

func (b *Bucket) Hash() error

func (*Bucket) Init

func (b *Bucket) Init() error

func (*Bucket) IsFull

func (b *Bucket) IsFull() (bool, error)

func (*Bucket) Unzip

func (b *Bucket) Unzip() error

func (*Bucket) Upload

func (b *Bucket) Upload(public bool) error

func (*Bucket) VerifyUnzipped

func (b *Bucket) VerifyUnzipped() error

func (*Bucket) VerifyZipped

func (b *Bucket) VerifyZipped() error

type Categories

type Categories struct {
	StorageBucketName string
	RelativeFilePath  string
	RemoteFilePath    string
	Dir               string
	FileName          string
	File              *os.File
	ZippedFileName    string
	ZippedFile        *os.File
	ZippedHash        string
	UnzippedHash      string
	CategoryItems     []CategoriesItem
	ErrorHandler      ErrorHandler
	Logger            Logger
	Storage           Storage
}

func NewCategories

func NewCategories(
	errorHandler ErrorHandler,
	logger Logger,
	storage Storage,
	storageBucketName,
	relativeFilePath,
	remoteFilePath,
	dir string,
	zippedHash,
	unzippedHash string,
	categoryItems []CategoriesItem,
) *Categories

func (*Categories) Compress

func (c *Categories) Compress() error

func (*Categories) Download

func (c *Categories) Download() error

func (*Categories) Hash

func (c *Categories) Hash() error

func (*Categories) Init

func (c *Categories) Init() error

func (*Categories) IsChanged

func (c *Categories) IsChanged() (bool, error)

func (*Categories) Upload

func (c *Categories) Upload(public bool) error

func (*Categories) Write

func (c *Categories) Write() error

type CategoriesItem

type CategoriesItem interface {
	GetId() int
	GetCategory() string
	GetSubcategory() string
	GetIdentifier() string
	GetDescription() string
	GetTlc() string
	GetSlc() string
}

type Config

type Config struct {
	StorageBucketName string
	RemoteDir         string
	Dir               string
	FileName          string
	Public            bool
	Validation        func(line []string, bucket *Bucket) error
	CategoryItems     []CategoriesItem
	ErrorHandler      ErrorHandler
	Logger            Logger
	Storage           Storage
}

type DefaultPatch

type DefaultPatch struct {
	Action string
	Key    string
	Values []string
}

func (*DefaultPatch) GetAction

func (d *DefaultPatch) GetAction() string

func (*DefaultPatch) GetKey

func (d *DefaultPatch) GetKey() string

func (*DefaultPatch) GetValues

func (d *DefaultPatch) GetValues() []string

type ErrorHandler

type ErrorHandler interface {
	Error(e error)
}

type Logger

type Logger interface {
	InfoF(category string, message string, args ...interface{})
	DebugF(category string, message string, args ...interface{})
}

type Master

type Master struct {
	StorageBucketName string
	RemoteDir         string
	Dir               string
	FileName          string
	Public            bool
	File              *os.File
	Categories        *Categories
	CategoryItems     []CategoriesItem
	IsChanged         bool
	Version           string
	UnixTime          int64
	DateTime          string
	Validation        func(line []string, bucket *Bucket) error
	Buckets           []*Bucket
	ErrorHandler      ErrorHandler
	Logger            Logger
	Storage           Storage
}

func NewMaster

func NewMaster(config Config) *Master

func (*Master) AddPatch

func (m *Master) AddPatch(patch Patch) error

func (*Master) CalculateWastage

func (m *Master) CalculateWastage() (int, error)

func (*Master) CleanupOldFiles

func (m *Master) CleanupOldFiles() error

func (*Master) CleanupOldLocalFiles added in v0.0.2

func (m *Master) CleanupOldLocalFiles() error

func (*Master) Close

func (m *Master) Close()

func (*Master) CompileList

func (m *Master) CompileList() (map[string][]string, error)

func (*Master) Download

func (m *Master) Download() error

func (*Master) DownloadBuckets

func (m *Master) DownloadBuckets() error

func (*Master) Init

func (m *Master) Init() error

func (*Master) InitCategories

func (m *Master) InitCategories() error

func (*Master) UploadToStorageBucket

func (m *Master) UploadToStorageBucket() error

type Patch

type Patch interface {
	GetAction() string
	GetKey() string
	GetValues() []string
}

type Storage

type Storage interface {
	DownloadWriter(bucket string, name string, writer io.Writer) error
	GetUploadWriter(bucket string, name string) (*storage.Writer, error)
	MakePublic(bucket string, name string) error
	GetDownloadReader(bucket string, name string) (io.ReadCloser, error)
	Ls(bucket string, dir string) ([]*storage.ObjectAttrs, error)
	Delete(bucket string, filePath string) error
}

Jump to

Keyboard shortcuts

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