adapters

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggerPortAdapter

func NewLoggerPortAdapter(adapter *logger.LoggerAdapter) application.Logger

NewLoggerPortAdapter creates a new adapter from LoggerAdapter

func NewOSPathOperations

func NewOSPathOperations() ports.PathOperations

NewOSPathOperations creates a new OS path operations adapter

Types

type LoggerPortAdapter

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

LoggerPortAdapter adapts logger.LoggerAdapter to ports.Logger interface This follows DIP: infrastructure implements the application port

func (*LoggerPortAdapter) Debug

func (l *LoggerPortAdapter) Debug(ctx context.Context, msg string, fields ...application.LogField)

Debug logs a debug-level message

func (*LoggerPortAdapter) Error

func (l *LoggerPortAdapter) Error(ctx context.Context, msg string, fields ...application.LogField)

Error logs an error-level message

func (*LoggerPortAdapter) Info

func (l *LoggerPortAdapter) Info(ctx context.Context, msg string, fields ...application.LogField)

Info logs an info-level message

func (*LoggerPortAdapter) Warn

func (l *LoggerPortAdapter) Warn(ctx context.Context, msg string, fields ...application.LogField)

Warn logs a warning-level message

type MockCommandExecutor

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

MockCommandExecutor implements CommandExecutor for testing

func NewMockCommandExecutor

func NewMockCommandExecutor() *MockCommandExecutor

NewMockCommandExecutor creates a new mock command executor

func (*MockCommandExecutor) Execute

Execute implements CommandExecutor interface

func (*MockCommandExecutor) SetError

func (m *MockCommandExecutor) SetError(signature string, err error)

SetError configures a mock error for a command

func (*MockCommandExecutor) SetResult

func (m *MockCommandExecutor) SetResult(signature string, result application.CommandResult)

SetResult configures a mock result for a command

type NoOpLogger

type NoOpLogger struct{}

NoOpLogger is a no-op logger implementation for when no logger is provided

func (*NoOpLogger) Debug

func (n *NoOpLogger) Debug(ctx context.Context, msg string, fields ...application.LogField)

Debug does nothing

func (*NoOpLogger) Error

func (n *NoOpLogger) Error(ctx context.Context, msg string, fields ...application.LogField)

Error does nothing

func (*NoOpLogger) Info

func (n *NoOpLogger) Info(ctx context.Context, msg string, fields ...application.LogField)

Info does nothing

func (*NoOpLogger) Warn

func (n *NoOpLogger) Warn(ctx context.Context, msg string, fields ...application.LogField)

Warn does nothing

type OSCommandExecutor

type OSCommandExecutor struct{}

OSCommandExecutor implements CommandExecutor using os/exec package This follows the Adapter pattern to bridge infrastructure and application layer

Design Principles: - Adapter Pattern: Bridges os/exec to application port - DIP: Infrastructure depends on application, not vice versa - Telemetry: Captures stdout/stderr for observability

func NewOSCommandExecutor

func NewOSCommandExecutor() *OSCommandExecutor

NewOSCommandExecutor creates a new OS command executor

func (*OSCommandExecutor) Execute

Execute implements CommandExecutor interface

type OSFileInfo

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

OSFileInfo implements ports.FileInfo using os.FileInfo

func (*OSFileInfo) IsDir

func (f *OSFileInfo) IsDir() bool

func (*OSFileInfo) ModTime

func (f *OSFileInfo) ModTime() time.Time

func (*OSFileInfo) Mode

func (f *OSFileInfo) Mode() fs.FileMode

func (*OSFileInfo) Name

func (f *OSFileInfo) Name() string

func (*OSFileInfo) Size

func (f *OSFileInfo) Size() int64

func (*OSFileInfo) Sys

func (f *OSFileInfo) Sys() interface{}

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem implements ports.FileSystem using the standard library's os package

func NewOSFileSystem

func NewOSFileSystem() *OSFileSystem

NewOSFileSystem creates a new OSFileSystem adapter

func (*OSFileSystem) IsNotExist

func (f *OSFileSystem) IsNotExist(err error) bool

IsNotExist checks if an error indicates a file doesn't exist

func (*OSFileSystem) MkdirAll

func (f *OSFileSystem) MkdirAll(ctx context.Context, path string, perm fs.FileMode) error

MkdirAll creates a directory and all parent directories

func (*OSFileSystem) ReadFile

func (f *OSFileSystem) ReadFile(ctx context.Context, path string) ([]byte, error)

ReadFile reads data from a file

func (*OSFileSystem) Remove

func (f *OSFileSystem) Remove(ctx context.Context, path string) error

Remove removes a file or directory

func (*OSFileSystem) Stat

func (f *OSFileSystem) Stat(ctx context.Context, path string) (ports.FileInfo, error)

Stat returns file information

func (f *OSFileSystem) Symlink(ctx context.Context, oldname, newname string) error

Symlink creates a symbolic link

func (*OSFileSystem) Sync

func (f *OSFileSystem) Sync(ctx context.Context) error

Sync synchronizes file system

func (*OSFileSystem) WriteFile

func (f *OSFileSystem) WriteFile(ctx context.Context, path string, data []byte, perm fs.FileMode) error

WriteFile writes data to a file

type OSPathOperations

type OSPathOperations struct{}

OSPathOperations implements PathOperations using the standard library

func (*OSPathOperations) Base

func (p *OSPathOperations) Base(path string) string

Base returns the last element of the path

func (*OSPathOperations) Clean

func (p *OSPathOperations) Clean(path string) string

Clean returns the shortest path name equivalent to path

func (*OSPathOperations) Dir

func (p *OSPathOperations) Dir(path string) string

Dir returns the directory part of the path

func (*OSPathOperations) Ext

func (p *OSPathOperations) Ext(path string) string

Ext returns the file extension

func (*OSPathOperations) IsAbs

func (p *OSPathOperations) IsAbs(path string) bool

IsAbs returns true if the path is absolute

func (*OSPathOperations) Join

func (p *OSPathOperations) Join(elem ...string) string

Join joins path elements

Jump to

Keyboard shortcuts

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