common

package module
v0.0.0-...-254845a Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMultiaddr

func DecodeMultiaddr(addr multiaddr.Multiaddr) (IPOrHost, IsHostName, PortNumber, error)

func EpochToTime

func EpochToTime(epoch int32) time.Time

func GetRequiredEnv

func GetRequiredEnv(key string) string

func MustSetEnv

func MustSetEnv(key, value string)

Types

type Content

type Content struct {
	CID string `bson:"cid"`
}

type DealID

type DealID struct {
	DealID int32 `bson:"deal_id"`
}

type DealState

type DealState struct {
	DealID     int32     `bson:"deal_id"`
	PieceCID   string    `bson:"piece_cid"`
	Label      string    `bson:"label"`
	Verified   bool      `bson:"verified"`
	Client     string    `bson:"client"`
	Provider   string    `bson:"provider"`
	Expiration time.Time `bson:"expiration"`
}

type IPInfo

type IPInfo struct {
	IP        string `json:"ip"`
	City      string `json:"city"`
	Region    string `json:"region"`
	Country   string `json:"country"`
	Continent string `json:"continent"`
	Loc       string `json:"loc"`
	Org       string `json:"org"`
	Postal    string `json:"postal"`
	Timezone  string `json:"timezone"`
	Bogon     bool   `json:"bogon"`
}

func GetPublicIPInfo

func GetPublicIPInfo(ctx context.Context, ip string, token string) (IPInfo, error)

type IPOrHost

type IPOrHost = string

type IsHostName

type IsHostName = bool

type LocationResolver

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

func NewLocationResolver

func NewLocationResolver(ipInfoToken string, ttl time.Duration) LocationResolver

func (LocationResolver) ResolveIP

func (l LocationResolver) ResolveIP(ctx context.Context, ip net.IP) (IPInfo, error)

func (LocationResolver) ResolveIPStr

func (l LocationResolver) ResolveIPStr(ctx context.Context, ip string) (IPInfo, error)

func (LocationResolver) ResolveMultiaddr

func (l LocationResolver) ResolveMultiaddr(ctx context.Context, addr multiaddr.Multiaddr) (IPInfo, error)

func (LocationResolver) ResolveMultiaddrs

func (l LocationResolver) ResolveMultiaddrs(ctx context.Context, addrs []multiaddr.Multiaddr) (IPInfo, error)

func (LocationResolver) ResolveMultiaddrsBytes

func (l LocationResolver) ResolveMultiaddrsBytes(ctx context.Context, bytesAddrs []abi.Multiaddrs) (IPInfo, error)

type ModuleName

type ModuleName string
const (
	Stub      ModuleName = "stub"
	GraphSync ModuleName = "graphsync"
	HTTP      ModuleName = "http"
	Bitswap   ModuleName = "bitswap"
)

type PortNumber

type PortNumber = int

type ProcessManager

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

func NewProcessManager

func NewProcessManager() (*ProcessManager, error)

func (ProcessManager) Run

func (p ProcessManager) Run(ctx context.Context)

type Provider

type Provider struct {
	ID        string `bson:"id"`
	Country   string `bson:"country,omitempty"`
	Continent string `bson:"continent,omitempty"`
}

type ProviderResolver

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

func NewProviderResolver

func NewProviderResolver(url string, token string, ttl time.Duration) (*ProviderResolver, error)

func (*ProviderResolver) Close

func (p *ProviderResolver) Close()

func (*ProviderResolver) ResolveProvider

func (p *ProviderResolver) ResolveProvider(ctx context.Context, provider string) (api.MinerInfo, error)

type RetrievalResult

type RetrievalResult struct {
	Success    bool    `bson:"success"`
	TTFB       int32   `bson:"ttfb,omitempty"`
	Speed      float32 `bson:"speed,omitempty"`
	Duration   int32   `bson:"duration,omitempty"`
	Downloaded int64   `bson:"downloaded,omitempty"`
}

type Retriever

type Retriever struct {
	PublicIP  string  `bson:"ip"`
	City      string  `bson:"city"`
	Region    string  `bson:"region"`
	Country   string  `bson:"country"`
	Continent string  `bson:"continent"`
	ASN       string  `bson:"asn"`
	Org       string  `bson:"org"`
	Latitude  float32 `bson:"lat"`
	Longitude float32 `bson:"long"`
}

type Task

type Task struct {
	Requester string                 `bson:"requester"`
	Module    ModuleName             `bson:"module"`
	Metadata  map[string]interface{} `bson:"metadata,omitempty"`
	Provider  Provider               `bson:"provider"`
	Content   Content                `bson:"content"`
	Options   map[string]interface{} `bson:"options,omitempty"`
	CreatedAt time.Time              `bson:"created_at"`
}

type TaskResult

type TaskResult struct {
	Task
	Retriever Retriever       `bson:"retriever"`
	Result    RetrievalResult `bson:"result"`
	CreatedAt time.Time       `bson:"created_at"`
}

type TaskWorker

type TaskWorker interface {
	DoWork(task Task) (RetrievalResult, error)
}

type TaskWorkerProcess

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

func NewTaskWorkerProcess

func NewTaskWorkerProcess(
	ctx context.Context,
	module ModuleName,
	worker TaskWorker) (*TaskWorkerProcess, error)

func (TaskWorkerProcess) Close

func (t TaskWorkerProcess) Close()

func (TaskWorkerProcess) Poll

func (t TaskWorkerProcess) Poll(ctx context.Context) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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