util

package
v0.0.0-...-c1b16d4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0, MIT Imports: 15 Imported by: 11

Documentation

Index

Constants

View Source
const ISO8601 = "2006-01-02T15:04:05.000Z"

Variables

This section is empty.

Functions

func RobustHTTPClient

func RobustHTTPClient() *http.Client

Generates an HTTP client with decent general-purpose defaults around timeouts and retries. The returned client has the stdlib http.Client interface, but has Hashicorp retryablehttp logic internally.

This client will retry on connection errors, 5xx status (except 501). It will log intermediate failures with WARN level. This does not start from http.DefaultClient.

This should be usable for XRPC clients, and other general inter-service client needs. CLI tools might want shorter timeouts and fewer retries by default.

func TestingHTTPClient

func TestingHTTPClient() *http.Client

For use in local integration tests. Short timeouts, no retries, etc

func XRPCRetryPolicy

func XRPCRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

XRPCRetryPolicy is a custom wrapper around retryablehttp.DefaultRetryPolicy. It treats `429 Too Many Requests` as non-retryable, so the application can decide how to deal with rate-limiting.

Types

type FakeKeyManager

type FakeKeyManager struct {
}

func (*FakeKeyManager) SignForUser

func (km *FakeKeyManager) SignForUser(ctx context.Context, did string, msg []byte) ([]byte, error)

func (*FakeKeyManager) VerifyUserSignature

func (km *FakeKeyManager) VerifyUserSignature(context.Context, string, []byte, []byte) error

type LeveledSlog

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

func (LeveledSlog) Debug

func (l LeveledSlog) Debug(msg string, keysAndValues ...interface{})

func (LeveledSlog) Error

func (l LeveledSlog) Error(msg string, keysAndValues ...interface{})

re-writes HTTP client ERROR to WARN level (because of retries)

func (LeveledSlog) Info

func (l LeveledSlog) Info(msg string, keysAndValues ...interface{})

func (LeveledSlog) Warn

func (l LeveledSlog) Warn(msg string, keysAndValues ...interface{})

type LoggingBstore

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

func NewLoggingBstore

func NewLoggingBstore(base blockstore.Blockstore) *LoggingBstore

func (*LoggingBstore) AllKeysChan

func (bs *LoggingBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

func (*LoggingBstore) DeleteBlock

func (bs *LoggingBstore) DeleteBlock(ctx context.Context, c cid.Cid) error

func (*LoggingBstore) Get

func (bs *LoggingBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error)

func (*LoggingBstore) GetLoggedBlocks

func (bs *LoggingBstore) GetLoggedBlocks() []blockformat.Block

func (*LoggingBstore) GetSize

func (bs *LoggingBstore) GetSize(ctx context.Context, c cid.Cid) (int, error)

func (*LoggingBstore) Has

func (bs *LoggingBstore) Has(ctx context.Context, c cid.Cid) (bool, error)

func (*LoggingBstore) HashOnRead

func (bs *LoggingBstore) HashOnRead(enabled bool)

func (*LoggingBstore) Put

func (*LoggingBstore) PutMany

type ParsedUri

type ParsedUri struct {
	Did        string
	Collection string
	Rkey       string
}

func ParseAtUri

func ParseAtUri(uri string) (*ParsedUri, error)

type ReadThroughBstore

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

func NewReadThroughBstore

func NewReadThroughBstore(base, fresh blockstore.Blockstore) *ReadThroughBstore

func (*ReadThroughBstore) AllKeysChan

func (bs *ReadThroughBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

func (*ReadThroughBstore) DeleteBlock

func (bs *ReadThroughBstore) DeleteBlock(ctx context.Context, c cid.Cid) error

func (*ReadThroughBstore) Get

func (bs *ReadThroughBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error)

func (*ReadThroughBstore) GetSize

func (bs *ReadThroughBstore) GetSize(ctx context.Context, c cid.Cid) (int, error)

func (*ReadThroughBstore) Has

func (bs *ReadThroughBstore) Has(ctx context.Context, c cid.Cid) (bool, error)

func (*ReadThroughBstore) HashOnRead

func (bs *ReadThroughBstore) HashOnRead(enabled bool)

func (*ReadThroughBstore) Put

func (*ReadThroughBstore) PutMany

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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