internal

package
v0.0.0-...-bc71f7a Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultInteractiveContinue = &InteractiveContinuePrinter{
	DefaultValueIndex: 0,
	DefaultText:       "Do you want to continue",
	TextStyle:         &pterm.ThemeDefault.PrimaryStyle,
	Options:           []string{"yes", "no", "all", "cancel"},
	OptionsStyle:      &pterm.ThemeDefault.SuccessMessageStyle,
	SuffixStyle:       &pterm.ThemeDefault.SecondaryStyle,
	Delimiter:         ": ",
}

DefaultInteractiveContinue is the default InteractiveContinue printer.

Functions

func NewRetryHTTPClient

func NewRetryHTTPClient(maxRetries uint) *http.Client

NewRetryHTTPClient creates an HTTP client with retry logic for network failures. It retries on temporary network errors (timeouts, connection refused, DNS errors, etc.) with exponential backoff. Non-retryable errors (4xx client errors) are not retried.

Types

type BoxoClientConfig

type BoxoClientConfig struct {
	MaxRetries uint
	MaxDelay   time.Duration
	MaxJitter  time.Duration
}

BoxoClientConfig holds configuration for BoxoPinningClient retry behavior.

func DefaultBoxoClientConfig

func DefaultBoxoClientConfig() BoxoClientConfig

DefaultBoxoClientConfig returns the default retry configuration.

type BoxoClientOption

type BoxoClientOption func(*BoxoClientConfig)

BoxoClientOption configures a BoxoPinningClient.

func WithMaxDelay

func WithMaxDelay(maxDelay time.Duration) BoxoClientOption

WithMaxDelay sets the maximum delay between retries.

func WithMaxJitter

func WithMaxJitter(maxJitter time.Duration) BoxoClientOption

WithMaxJitter sets the maximum jitter to add to delays.

func WithMaxRetries

func WithMaxRetries(maxRetries uint) BoxoClientOption

WithMaxRetries sets the maximum number of retry attempts.

type BoxoPinningClient

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

BoxoPinningClient wraps the boxo pinning service HTTP client.

func (*BoxoPinningClient) Add

Add implements PinningClient.Add.

func (*BoxoPinningClient) DeleteByID

func (c *BoxoPinningClient) DeleteByID(ctx context.Context, pinID string) error

DeleteByID implements PinningClient.DeleteByID.

func (*BoxoPinningClient) GetStatusByID

GetStatusByID implements PinningClient.GetStatusByID.

func (*BoxoPinningClient) LsSync

LsSync implements PinningClient.LsSync.

func (*BoxoPinningClient) Replace

Replace implements PinningClient.Replace.

type InteractiveContinuePrinter

type InteractiveContinuePrinter struct {
	DefaultValueIndex int
	DefaultText       string
	Delimiter         string
	TextStyle         *pterm.Style
	Options           []string
	OptionsStyle      *pterm.Style
	Handles           []string
	ShowShortHandles  bool
	SuffixStyle       *pterm.Style
}

InteractiveContinuePrinter is a printer for interactive continue prompts. This is a copy of PTerm's InteractiveContinuePrinter that handles Ctrl+C gracefully.

func (*InteractiveContinuePrinter) Show

func (p *InteractiveContinuePrinter) Show(text ...string) (string, error)

Show shows the continue prompt.

func (*InteractiveContinuePrinter) WithDefaultText

WithDefaultText sets the default text.

func (*InteractiveContinuePrinter) WithDefaultValue

func (p *InteractiveContinuePrinter) WithDefaultValue(value string) *InteractiveContinuePrinter

WithDefaultValue sets the default value.

func (*InteractiveContinuePrinter) WithDefaultValueIndex

func (p *InteractiveContinuePrinter) WithDefaultValueIndex(value int) *InteractiveContinuePrinter

WithDefaultValueIndex sets the default value.

func (*InteractiveContinuePrinter) WithDelimiter

func (p *InteractiveContinuePrinter) WithDelimiter(delimiter string) *InteractiveContinuePrinter

WithDelimiter sets the delimiter.

func (*InteractiveContinuePrinter) WithHandles

WithHandles allows you to customize the short handles.

func (*InteractiveContinuePrinter) WithOptions

WithOptions sets the options.

func (*InteractiveContinuePrinter) WithOptionsStyle

WithOptionsStyle sets the continue style.

func (*InteractiveContinuePrinter) WithShowShortHandles

func (p *InteractiveContinuePrinter) WithShowShortHandles(b ...bool) *InteractiveContinuePrinter

WithShowShortHandles will set ShowShortHandles to true.

func (*InteractiveContinuePrinter) WithSuffixStyle

WithSuffixStyle sets the suffix style.

func (*InteractiveContinuePrinter) WithTextStyle

WithTextStyle sets the text style.

type PinningClient

type PinningClient interface {
	// Add pins a CID to the pinning service with optional options.
	Add(ctx context.Context, cid cid.Cid, opts ...go_pinning_service_http_client.AddOption) (go_pinning_service_http_client.PinStatusGetter, error)

	// LsSync lists pins synchronously with optional filters.
	LsSync(ctx context.Context, opts ...go_pinning_service_http_client.LsOption) ([]go_pinning_service_http_client.PinStatusGetter, error)

	// GetStatusByID retrieves pin status by request ID.
	GetStatusByID(ctx context.Context, pinID string) (go_pinning_service_http_client.PinStatusGetter, error)

	// DeleteByID removes a pin by request ID.
	DeleteByID(ctx context.Context, pinID string) error

	// Replace replaces an existing pin with a new CID and options.
	Replace(ctx context.Context, pinID string, cid cid.Cid, opts ...go_pinning_service_http_client.AddOption) (go_pinning_service_http_client.PinStatusGetter, error)
}

PinningClient defines the interface for IPFS pinning service client operations.

func NewBoxoPinningClient

func NewBoxoPinningClient(endpoint, authToken string, opts ...BoxoClientOption) PinningClient

NewBoxoPinningClient creates a new BoxoPinningClient wrapping the boxo client. Uses default retry configuration unless options are provided.

type PinningClientFactory

type PinningClientFactory func(endpoint, authToken string) PinningClient

PinningClientFactory creates a PinningClient with the given endpoint and auth token.

type RetryConfig

type RetryConfig struct {
	MaxRetries uint
	MaxDelay   time.Duration
}

RetryConfig holds configuration for retry behavior.

func DefaultRetryConfig

func DefaultRetryConfig() RetryConfig

DefaultRetryConfig returns default retry configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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