file_progress_store

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 5 Imported by: 0

README

File Progress Index Store

Stores current progress of a process index

Installation
go get github.com/matt9mg/go-file-progress-index-store
Examples
fpis, err := file_progress_store.NewFileProgressStore[string]("/my/file/location/file.json")

if err != nil {
	log.Fatalln(err)
}

data := []string{"1", "2", "3"}

unprocessed := fpis.ReturnUnprocessed(data)

if len(data) > 0 {
	// perform some business logic
	if err := fpis.Save(unprocessed); err != nil {
		log.Fatalln(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileProgressStore

type FileProgressStore[T indexTypes] struct {
	// contains filtered or unexported fields
}

func NewFileProgressStore

func NewFileProgressStore[T indexTypes](fileStore string) (*FileProgressStore[T], error)

NewFileProgressStore takes a storage file and its location and returns a FileProgressStore of its type or an error

func (*FileProgressStore[T]) ReturnUnprocessed

func (f *FileProgressStore[T]) ReturnUnprocessed(toProcess []T) []T

ReturnUnprocessed checks to see if the items you wish to process have already been processed and stored within the current result set, this should be called be Save to check

func (*FileProgressStore[T]) Save

func (f *FileProgressStore[T]) Save(items ...T) error

FileProgressStore appends the items to save an error is returned if the data cannot be saved

Jump to

Keyboard shortcuts

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