server

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrBadRouting is returned when an expected path variable is missing, which is always programmer error.
	ErrBadRouting = fmt.Errorf("inconsistent mapping between route and handler, %s", bugReportHelp)
	ErrFoundABug  = fmt.Errorf("snuck into encodeError with err == nil, %s", bugReportHelp)
)
View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
)

Functions

func MakeHTTPHandler

func MakeHTTPHandler(s Service, repo Repository, logger log.Logger) http.Handler

Types

type Repository

type Repository interface {
	StoreFile(file *ach.File) error
	FindFile(id string) (*ach.File, error)
	FindAllFiles() []*ach.File
	DeleteFile(id string) error
	StoreBatch(fileID string, batch ach.Batcher) error
	FindBatch(fileID string, batchID string) (ach.Batcher, error)
	FindAllBatches(fileID string) []ach.Batcher
	DeleteBatch(fileID string, batchID string) error
}

Repository is the Service storage mechanism abstraction

func NewRepositoryInMemory

func NewRepositoryInMemory(ttl time.Duration, logger log.Logger) Repository

NewRepositoryInMemory is an in memory ach storage repository for files

type Service

type Service interface {
	// CreateFile creates a new ach file record and returns a resource ID
	CreateFile(f *ach.FileHeader) (string, error)
	// AddFile retrieves a file based on the File id
	GetFile(id string) (*ach.File, error)
	// GetFiles retrieves all files accessible from the client.
	GetFiles() []*ach.File
	// DeleteFile takes a file resource ID and deletes it from the store
	DeleteFile(id string) error
	// GetFileContents creates a valid plaintext file in memory assuming it has a FileHeader and at least one Batch record.
	GetFileContents(id string) (io.Reader, error)
	// ValidateFile
	ValidateFile(id string, opts *ach.ValidateOpts) error
	// BalanceFile will apply a given offset record to the file
	BalanceFile(fileID string, off *ach.Offset) (*ach.File, error)
	// SegmentFile segments an ach file
	SegmentFile(id string, opts *ach.SegmentFileConfiguration) (*ach.File, *ach.File, error)
	// FlattenBatches will minimize the ach.Batch objects in a file by consolidating EntryDetails under distinct batch headers
	FlattenBatches(id string) (*ach.File, error)
	// CreateBatch creates a new batch within and ach file and returns its resource ID
	CreateBatch(fileID string, bh ach.Batcher) (string, error)
	// GetBatch retrieves a batch based oin the file id and batch id
	GetBatch(fileID string, batchID string) (ach.Batcher, error)
	// GetBatches retrieves all batches associated with the file id.
	GetBatches(fileID string) []ach.Batcher
	// DeleteBatch takes a fileID and BatchID and removes the batch from the file
	DeleteBatch(fileID string, batchID string) error
}

Service is a REST interface for interacting with ACH file structures TODO: Add ctx to function parameters to pass the client security token

func NewService

func NewService(r Repository) Service

NewService creates a new concrete service

Jump to

Keyboard shortcuts

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