resources

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package resources

Summary

This package collect CRUD interface based signature contracts that commonly appears upon interacting with external resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupID

func LookupID(i interface{}) (string, bool)

func SetID

func SetID(i interface{}, newID string) error

Types

type Creator

type Creator interface {
	// Create takes a ptr to a entity<T> and store it into the resource.
	// It also updates the entity<T> ext:"ID" field with the associated uniq resource id.
	// The reason behind this links the id and not returning the id is that,
	// in most case the Create error value is the only thing that is checked for errors,
	// and introducing an extra value also introduce boiler plates in the handling.
	Create(ctx context.Context, ptr interface{}) error
}

type Deleter

type Deleter interface {
	// DeleteByID will remove a <T> type entity from the storage by a given ID
	DeleteByID(ctx context.Context, T interface{}, id string) error
}

Deleter request to destroy a business entity in the Resource that implement it's test.

type Finder

type Finder interface {
	// FindByID will link an entity that is found in the resource to the received ptr,
	// and report back if it succeeded finding the entity in the resource.
	// It also reports if there was an unexpected exception during the execution.
	// It was an intentional decision to not use error to represent "not found" case,
	// but tell explicitly this information in the form of return bool value.
	FindByID(ctx context.Context, ptr interface{}, id string) (_found bool, _err error)
	// FindAll will return all entity that has <T> type
	FindAll(ctx context.Context, T interface{}) frameless.Iterator
}

type TestEntity

type TestEntity struct {
	ID string `ext:"ID"`
}

type Truncater

type Truncater interface {
	// Truncate will erase all entity from the resource that has <T> type
	Truncate(ctx context.Context, T interface{}) error
}

type Updater

type Updater interface {
	// Update will takes a ptr that points to an entity
	// and update the corresponding stored entity with the received entity field values
	Update(ctx context.Context, ptr interface{}) error
}

Directories

Path Synopsis
Package specs Summary This package implements generic CRUD operation related testing specifications that commonly appears upon interacting with external resources.
Package specs Summary This package implements generic CRUD operation related testing specifications that commonly appears upon interacting with external resources.

Jump to

Keyboard shortcuts

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