Documentation
¶
Overview ¶
Package network provides concrete implementations of network diagnostic operations
Package network provides mock implementations for testing ¶
Package network provides network operation implementations ¶
Package network provides retry logic for network operations
Index ¶
- type Client
- func (c *Client) DNSLookup(ctx context.Context, domainName string, recordType domain.DNSRecordType) (domain.DNSResult, error)
- func (c *Client) Ping(ctx context.Context, host string, opts domain.PingOptions) (<-chan domain.PingResult, error)
- func (c *Client) SSLCheck(ctx context.Context, host string, port int) (domain.SSLResult, error)
- func (c *Client) Traceroute(ctx context.Context, host string, opts domain.TraceOptions) (<-chan domain.TraceHop, error)
- func (c *Client) WHOISLookup(ctx context.Context, query string) (domain.WHOISResult, error)
- type MockCall
- type MockClient
- func (m *MockClient) DNSLookup(ctx context.Context, domainName string, recordType domain.DNSRecordType) (domain.DNSResult, error)
- func (m *MockClient) GetCallCount() int
- func (m *MockClient) GetDNSCalls() []MockCall
- func (m *MockClient) GetPingCalls() []MockCall
- func (m *MockClient) GetSSLCalls() []MockCall
- func (m *MockClient) GetTraceCalls() []MockCall
- func (m *MockClient) GetWHOISCalls() []MockCall
- func (m *MockClient) Ping(ctx context.Context, host string, opts domain.PingOptions) (<-chan domain.PingResult, error)
- func (m *MockClient) Reset()
- func (m *MockClient) SSLCheck(ctx context.Context, host string, port int) (domain.SSLResult, error)
- func (m *MockClient) SetDNSError(domainName string, recordType domain.DNSRecordType, err error)
- func (m *MockClient) SetDNSResponse(domainName string, recordType domain.DNSRecordType, result domain.DNSResult)
- func (m *MockClient) SetPingDelay(host string, delay time.Duration)
- func (m *MockClient) SetPingError(host string, err error)
- func (m *MockClient) SetPingResponse(host string, results []domain.PingResult)
- func (m *MockClient) SetSSLError(host string, port int, err error)
- func (m *MockClient) SetSSLResponse(host string, port int, result domain.SSLResult)
- func (m *MockClient) SetSimulateNetworkError(simulate bool)
- func (m *MockClient) SetSimulateTimeout(simulate bool)
- func (m *MockClient) SetTraceError(host string, err error)
- func (m *MockClient) SetTraceResponse(host string, hops []domain.TraceHop)
- func (m *MockClient) SetWHOISError(query string, err error)
- func (m *MockClient) SetWHOISResponse(query string, result domain.WHOISResult)
- func (m *MockClient) Traceroute(ctx context.Context, host string, opts domain.TraceOptions) (<-chan domain.TraceHop, error)
- func (m *MockClient) WHOISLookup(ctx context.Context, query string) (domain.WHOISResult, error)
- type RetryManager
- func (rm *RetryManager) ExecuteWithCustomRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc, ...) (interface{}, error)
- func (rm *RetryManager) ExecuteWithLinearRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc) (interface{}, error)
- func (rm *RetryManager) ExecuteWithRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc) (interface{}, error)
- func (rm *RetryManager) GetBaseDelay() time.Duration
- func (rm *RetryManager) GetMaxAttempts() int
- func (rm *RetryManager) SetBaseDelay(baseDelay time.Duration)
- func (rm *RetryManager) SetMaxAttempts(maxAttempts int)
- type RetryableFunc
- type ShouldRetryFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the NetworkClient interface with real network operations
func NewClient ¶
func NewClient(config *domain.NetworkConfig, errorHandler domain.ErrorHandler, logger domain.Logger) *Client
NewClient creates a new network client with the provided configuration
func (*Client) DNSLookup ¶
func (c *Client) DNSLookup(ctx context.Context, domainName string, recordType domain.DNSRecordType) (domain.DNSResult, error)
DNSLookup performs DNS lookups for the specified domain and record type
func (*Client) Ping ¶
func (c *Client) Ping(ctx context.Context, host string, opts domain.PingOptions) (<-chan domain.PingResult, error)
Ping performs ping operations to the specified host
func (*Client) Traceroute ¶
func (c *Client) Traceroute(ctx context.Context, host string, opts domain.TraceOptions) (<-chan domain.TraceHop, error)
Traceroute performs traceroute operations to the specified host
func (*Client) WHOISLookup ¶
WHOISLookup performs WHOIS lookups for the specified query
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient implements the NetworkClient interface for testing
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient creates a new mock network client
func (*MockClient) DNSLookup ¶
func (m *MockClient) DNSLookup(ctx context.Context, domainName string, recordType domain.DNSRecordType) (domain.DNSResult, error)
DNSLookup implements the NetworkClient interface with mock behavior
func (*MockClient) GetCallCount ¶
func (m *MockClient) GetCallCount() int
GetCallCount returns the total number of method calls made
func (*MockClient) GetDNSCalls ¶
func (m *MockClient) GetDNSCalls() []MockCall
GetDNSCalls returns all recorded DNS calls
func (*MockClient) GetPingCalls ¶
func (m *MockClient) GetPingCalls() []MockCall
GetPingCalls returns all recorded ping calls
func (*MockClient) GetSSLCalls ¶
func (m *MockClient) GetSSLCalls() []MockCall
GetSSLCalls returns all recorded SSL calls
func (*MockClient) GetTraceCalls ¶
func (m *MockClient) GetTraceCalls() []MockCall
GetTraceCalls returns all recorded traceroute calls
func (*MockClient) GetWHOISCalls ¶
func (m *MockClient) GetWHOISCalls() []MockCall
GetWHOISCalls returns all recorded WHOIS calls
func (*MockClient) Ping ¶
func (m *MockClient) Ping(ctx context.Context, host string, opts domain.PingOptions) (<-chan domain.PingResult, error)
Ping implements the NetworkClient interface with mock behavior
func (*MockClient) Reset ¶
func (m *MockClient) Reset()
Reset clears all recorded calls and configured responses
func (*MockClient) SetDNSError ¶
func (m *MockClient) SetDNSError(domainName string, recordType domain.DNSRecordType, err error)
SetDNSError configures a mock DNS error for a specific domain and record type
func (*MockClient) SetDNSResponse ¶
func (m *MockClient) SetDNSResponse(domainName string, recordType domain.DNSRecordType, result domain.DNSResult)
SetDNSResponse configures a mock DNS response for a specific domain and record type
func (*MockClient) SetPingDelay ¶
func (m *MockClient) SetPingDelay(host string, delay time.Duration)
SetPingDelay configures a mock ping delay for a specific host
func (*MockClient) SetPingError ¶
func (m *MockClient) SetPingError(host string, err error)
SetPingError configures a mock ping error for a specific host
func (*MockClient) SetPingResponse ¶
func (m *MockClient) SetPingResponse(host string, results []domain.PingResult)
SetPingResponse configures a mock ping response for a specific host
func (*MockClient) SetSSLError ¶
func (m *MockClient) SetSSLError(host string, port int, err error)
SetSSLError configures a mock SSL error for a specific host and port
func (*MockClient) SetSSLResponse ¶
func (m *MockClient) SetSSLResponse(host string, port int, result domain.SSLResult)
SetSSLResponse configures a mock SSL response for a specific host and port
func (*MockClient) SetSimulateNetworkError ¶
func (m *MockClient) SetSimulateNetworkError(simulate bool)
SetSimulateNetworkError enables or disables network error simulation
func (*MockClient) SetSimulateTimeout ¶
func (m *MockClient) SetSimulateTimeout(simulate bool)
SetSimulateTimeout enables or disables timeout simulation
func (*MockClient) SetTraceError ¶
func (m *MockClient) SetTraceError(host string, err error)
SetTraceError configures a mock traceroute error for a specific host
func (*MockClient) SetTraceResponse ¶
func (m *MockClient) SetTraceResponse(host string, hops []domain.TraceHop)
SetTraceResponse configures a mock traceroute response for a specific host
func (*MockClient) SetWHOISError ¶
func (m *MockClient) SetWHOISError(query string, err error)
SetWHOISError configures a mock WHOIS error for a specific query
func (*MockClient) SetWHOISResponse ¶
func (m *MockClient) SetWHOISResponse(query string, result domain.WHOISResult)
SetWHOISResponse configures a mock WHOIS response for a specific query
func (*MockClient) Traceroute ¶
func (m *MockClient) Traceroute(ctx context.Context, host string, opts domain.TraceOptions) (<-chan domain.TraceHop, error)
Traceroute implements the NetworkClient interface with mock behavior
func (*MockClient) WHOISLookup ¶
func (m *MockClient) WHOISLookup(ctx context.Context, query string) (domain.WHOISResult, error)
WHOISLookup implements the NetworkClient interface with mock behavior
type RetryManager ¶
type RetryManager struct {
// contains filtered or unexported fields
}
RetryManager handles retry logic for network operations
func NewRetryManager ¶
func NewRetryManager(maxAttempts int, baseDelay time.Duration) *RetryManager
NewRetryManager creates a new retry manager with the specified configuration
func (*RetryManager) ExecuteWithCustomRetry ¶
func (rm *RetryManager) ExecuteWithCustomRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc, delayFunc func(int) time.Duration) (interface{}, error)
ExecuteWithCustomRetry executes a function with custom retry logic
func (*RetryManager) ExecuteWithLinearRetry ¶
func (rm *RetryManager) ExecuteWithLinearRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc) (interface{}, error)
ExecuteWithLinearRetry executes a function with linear backoff retry logic
func (*RetryManager) ExecuteWithRetry ¶
func (rm *RetryManager) ExecuteWithRetry(ctx context.Context, fn RetryableFunc, shouldRetry ShouldRetryFunc) (interface{}, error)
ExecuteWithRetry executes a function with exponential backoff retry logic
func (*RetryManager) GetBaseDelay ¶
func (rm *RetryManager) GetBaseDelay() time.Duration
GetBaseDelay returns the base delay for retry operations
func (*RetryManager) GetMaxAttempts ¶
func (rm *RetryManager) GetMaxAttempts() int
GetMaxAttempts returns the maximum number of retry attempts
func (*RetryManager) SetBaseDelay ¶
func (rm *RetryManager) SetBaseDelay(baseDelay time.Duration)
SetBaseDelay updates the base delay for retry operations
func (*RetryManager) SetMaxAttempts ¶
func (rm *RetryManager) SetMaxAttempts(maxAttempts int)
SetMaxAttempts updates the maximum number of retry attempts
type RetryableFunc ¶
type RetryableFunc func() (interface{}, error)
RetryableFunc represents a function that can be retried
type ShouldRetryFunc ¶
ShouldRetryFunc determines if an error should trigger a retry