targets

package
v0.0.0-...-4c05313 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider(id string, createFunc InitFunc) error

func TestTarget

func TestTarget(t *testing.T, target Target)

Types

type Completer

type Completer func(status TargetError)

type Executer

type Executer func(r *IORequest)

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

func (*Factory) New

func (f *Factory) New(id string, options Options) (Target, error)

func (*Factory) RegisterProvider

func (f *Factory) RegisterProvider(id string, createFunc InitFunc) error

type FileTarget

type FileTarget struct {
	File *os.File
	// contains filtered or unexported fields
}

FileTarget implements target that write to file image

func (*FileTarget) Close

func (t *FileTarget) Close() error

func (*FileTarget) GetRuntimeDetails

func (t *FileTarget) GetRuntimeDetails() []KV

func (*FileTarget) GetSize

func (t *FileTarget) GetSize() uint64

func (*FileTarget) Queue

func (t *FileTarget) Queue(r *IORequest) TargetError

func (*FileTarget) Start

func (t *FileTarget) Start() error

type Handler

type Handler interface {
	Handle(r *IORequest)
}

type IORequest

type IORequest struct {
	Command         TargetCommand
	Lba             uint64
	Length          uint32
	SGL             [16]SGE
	SGLC            int
	ExecuteRequest  Executer
	CompleteRequest Completer
}

func (*IORequest) AddBuffer

func (r *IORequest) AddBuffer(buffer []byte)

func (*IORequest) Assert

func (r *IORequest) Assert() error

func (*IORequest) Buffers

func (r *IORequest) Buffers() []SGE

func (*IORequest) Complete

func (r *IORequest) Complete(status TargetError) TargetError

func (*IORequest) Init

func (r *IORequest) Init(c TargetCommand, lba uint64, length uint32, completion Completer) *IORequest

func (*IORequest) SetExecuter

func (r *IORequest) SetExecuter(e Executer)

func (*IORequest) Start

func (r *IORequest) Start()

type InitFunc

type InitFunc func(options Options) (Target, error)

type KV

type KV struct {
	Key   string
	Value string
}

KV contains a key value pair

type MemTarget

type MemTarget struct {
	Buffer []byte
}

MemTarget implements target that write to file image

func (*MemTarget) Close

func (t *MemTarget) Close() error

func (*MemTarget) GetRuntimeDetails

func (t *MemTarget) GetRuntimeDetails() []KV

func (*MemTarget) GetSize

func (t *MemTarget) GetSize() uint64

func (*MemTarget) Queue

func (t *MemTarget) Queue(r *IORequest) TargetError

func (*MemTarget) Start

func (t *MemTarget) Start() error

type NullTarget

type NullTarget struct {
	Size uint64
}

func NewNullTarget

func NewNullTarget(options Options) *NullTarget

func (*NullTarget) Close

func (t *NullTarget) Close() error

func (*NullTarget) GetRuntimeDetails

func (t *NullTarget) GetRuntimeDetails() []KV

func (*NullTarget) GetSize

func (t *NullTarget) GetSize() uint64

func (*NullTarget) Queue

func (t *NullTarget) Queue(r *IORequest) TargetError

func (*NullTarget) Start

func (t *NullTarget) Start() error

type Options

type Options map[string]string

func (Options) Int

func (o Options) Int(key string, def int) int

func (Options) String

func (o Options) String(key string) string

func (Options) Uint64

func (o Options) Uint64(key string, def uint64) uint64

func (Options) With

func (o Options) With(key string, data interface{}) Options

type SGE

type SGE struct {
	Data []byte
}

SGE defines a Scatter Gather Element

type SleepyTarget

type SleepyTarget struct {
	Size      uint64
	SleepTime time.Duration
}

func (*SleepyTarget) Close

func (t *SleepyTarget) Close() error

func (*SleepyTarget) GetRuntimeDetails

func (t *SleepyTarget) GetRuntimeDetails() []KV

func (*SleepyTarget) GetSize

func (t *SleepyTarget) GetSize() uint64

func (*SleepyTarget) Queue

func (t *SleepyTarget) Queue(r *IORequest) TargetError

func (*SleepyTarget) Start

func (t *SleepyTarget) Start() error

type Target

type Target interface {
	// Start performs any required initialization of the target
	Start() error
	// Queue enqueue the request for processing
	Queue(r *IORequest) TargetError
	// GetSize the current size (in bytes) of the target
	GetSize() uint64
	// Close terminates any background tasks the target m ay be doing
	Close() error
	// GetRuntimeDetails returns internal configuration information about the target
	GetRuntimeDetails() []KV
}

func FILECreateTarget

func FILECreateTarget(options Options) (Target, error)

func MEMCreateTarget

func MEMCreateTarget(options Options) (Target, error)

func New

func New(id string, options Options) (Target, error)

func SleepyCreateTarget

func SleepyCreateTarget(options Options) (Target, error)

type TargetCommand

type TargetCommand uint8
const (
	IORequestCmdRead      TargetCommand = 0x1
	IORequestCmdWrite     TargetCommand = 0x2
	IORequestCmdTrim      TargetCommand = 0x3
	IORequestCmdWriteZero TargetCommand = 0x4
	IORequestCmdFlush     TargetCommand = 0x5

	IORequestSnapshot TargetCommand = 0x20
)

type TargetError

type TargetError uint16
const (
	TargetErrorNone          TargetError = 0x0
	TargetErrorUnsupported   TargetError = 0x1
	TargetErrorAborted       TargetError = 0x3
	TargetErrorLbaOutOfRange TargetError = 0x4

	TargetErrorWrite    TargetError = 0x5
	TargetErrorRead     TargetError = 0x6
	TargetErrorInternal TargetError = 0xffff
)

func TestRequest

func TestRequest(t Target, r *IORequest) TargetError

type TestCompleter

type TestCompleter struct {
	Wait sync.WaitGroup
	// contains filtered or unexported fields
}

func (*TestCompleter) Complete

func (t *TestCompleter) Complete(status TargetError)

type TestableMediaRegion

type TestableMediaRegion struct {
	Start     uint64
	End       uint64
	FailRead  bool
	FailWrite bool
}

type TestableTarget

type TestableTarget struct {
	SleepTime time.Duration

	ReadCount  uint64
	WriteCount uint64
	TrimCount  uint64
	ZeroCount  uint64
	FlushCount uint64

	Buffer  []byte
	Regions []TestableMediaRegion
}

func NewTestableTarget

func NewTestableTarget(options Options) *TestableTarget

func (*TestableTarget) Close

func (t *TestableTarget) Close() error

func (*TestableTarget) GetRuntimeDetails

func (t *TestableTarget) GetRuntimeDetails() []KV

func (*TestableTarget) GetSize

func (t *TestableTarget) GetSize() uint64

func (*TestableTarget) Queue

func (t *TestableTarget) Queue(r *IORequest) TargetError

func (*TestableTarget) Start

func (t *TestableTarget) Start() error

type WorkQueue

type WorkQueue struct {
	Handler Target
	// contains filtered or unexported fields
}

func NewWorkQueue

func NewWorkQueue(options map[string]string, h Target) *WorkQueue

func (*WorkQueue) Close

func (w *WorkQueue) Close() error

func (*WorkQueue) GetRuntimeDetails

func (w *WorkQueue) GetRuntimeDetails() []KV

func (*WorkQueue) GetSize

func (w *WorkQueue) GetSize() uint64

GetSize in bytes

func (*WorkQueue) Queue

func (w *WorkQueue) Queue(r *IORequest) TargetError

func (*WorkQueue) Start

func (w *WorkQueue) Start() error

func (*WorkQueue) Work

func (w *WorkQueue) Work()

Jump to

Keyboard shortcuts

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