Documentation
¶
Index ¶
Constants ¶
View Source
const ( RequiredBandDown = 500 * 1 << 20 / 8 // 500Mbps 62.5MB/s RequiredBandUp = 200 * 1 << 20 / 8 // 200Mbps 25MB/s LowStress = 0.2 // low stress of peak0. will degrade to peak1 Peak0LowTask = 1 Peak1LowTask = 5 Peak0WindowSize = 60 Peak1WindowSize = 600 )
View Source
const ( Pending taskStatus = "pending" InProgress taskStatus = "inprogress" Completed taskStatus = "complete" Failed taskStatus = "failed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset interface {
// GetAsset fetches the asset data for a given CID and returns an io.ReadSeekCloser.
GetAsset(root cid.Cid) (io.ReadSeekCloser, error)
// AssetExists checks whether the asset data for a given CID exists or not.
AssetExists(root cid.Cid) (bool, error)
// HasBlock checks if a block with the given CID is present in the asset data for a given root CID.
HasBlock(ctx context.Context, root, block cid.Cid) (bool, error)
// GetBlock retrieves a block with the given CID from the asset data for a given root CID.
GetBlock(ctx context.Context, root, block cid.Cid) (blocks.Block, error)
// SaveUserAsset save user asset to local
SaveUserAsset(ctx context.Context, userID string, root cid.Cid, assetSize int64, r io.Reader) error
// SetAssetUploadProgress set progress of upload for asset
SetAssetUploadProgress(ctx context.Context, root cid.Cid, progress *types.UploadProgress) error
// GetUploadingAsset get asset which uploading
GetUploadingAsset(ctx context.Context, root cid.Cid) (*types.UploadingAsset, error)
// AllocatePathWithSize allocate path for storage file
AllocatePathWithSize(size int64) (string, error)
// ListBlocks returns the sub-cids of a certain root-cid
ListBlocks(ctx context.Context, root cid.Cid) ([]cid.Cid, error)
}
Asset represents an interface for fetching and checking asset data.
type DirectoryResult ¶ added in v0.1.11
type FileList ¶ added in v0.1.11
type FileList struct {
FileProperties []FileProperty
Name string
Size int64
Total int
}
type FileProperty ¶ added in v0.1.11
SubAsset the content of directory
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(opts *HttpServerOptions) *HttpServer
NewHttpServer creates a new HttpServer with the given Asset, Scheduler, and RSA private key.
func (*HttpServer) FirstToken ¶ added in v0.1.10
func (hs *HttpServer) FirstToken() string
GetDownloadThreadCount get download thread count of httpserver
func (*HttpServer) NewHandler ¶
func (hs *HttpServer) NewHandler(handler http.Handler) http.Handler
NewHandler creates a new Handler with the given HTTP handler
func (*HttpServer) Stats ¶ added in v0.1.22
func (hs *HttpServer) Stats() *types.KeepaliveReq
type HttpServerOptions ¶ added in v0.1.10
type HttpServerOptions struct {
Asset Asset
Scheduler api.Scheduler
PrivateKey *rsa.PrivateKey
Validation Validation
APISecret *jwt.HMACSHA
MaxSizeOfUploadFile int64
WebRedirect string
RateLimiter *types.RateLimiter
}
type Monitor ¶ added in v0.1.22
type Monitor struct {
Routes *RouteLoads
Loads [Peak1WindowSize]FlowUnit
Peak0 FlowUnit // peak in window
Peak1 FlowUnit // peak in last 10 rinutes
Peak2 FlowUnit // peak since last run
// contains filtered or unexported fields
}
func NewMonitor ¶ added in v0.1.22
func NewMonitor() *Monitor
func (*Monitor) Middleware ¶ added in v0.1.22
func (m *Monitor) Middleware(next http.HandlerFunc) http.HandlerFunc
type ProgressReader ¶ added in v0.1.10
type ProgressReader struct {
// contains filtered or unexported fields
}
type RouteInstance ¶ added in v0.1.22
type RouteInstance struct {
// contains filtered or unexported fields
}
RouteInstance should include start and end times, writer and reader, number of bytes read and written, and the route name. Requests that lasted more than 10 minutes and have already ended should be discarded.
func NewRouterInstance ¶ added in v0.1.22
func NewRouterInstance(name string, w http.ResponseWriter, r *http.Request) *RouteInstance
func (*RouteInstance) Close ¶ added in v0.1.22
func (ri *RouteInstance) Close() error
impl io.ReadCloser
func (*RouteInstance) Header ¶ added in v0.1.22
func (ri *RouteInstance) Header() http.Header
impl ResponseWriter
func (*RouteInstance) IsRunning ¶ added in v0.1.22
func (ri *RouteInstance) IsRunning() bool
func (*RouteInstance) Read ¶ added in v0.1.22
func (ri *RouteInstance) Read(p []byte) (int, error)
impl io.ReadCloser
func (*RouteInstance) Write ¶ added in v0.1.22
func (ri *RouteInstance) Write(b []byte) (int, error)
impl ResponseWriter
func (*RouteInstance) WriteHeader ¶ added in v0.1.22
func (ri *RouteInstance) WriteHeader(statusCode int)
impl ResponseWriter
type RouteLoads ¶ added in v0.1.22
func (*RouteLoads) AddRoute ¶ added in v0.1.22
func (rl *RouteLoads) AddRoute(ri *RouteInstance)
func (*RouteLoads) Cleanup ¶ added in v0.1.22
func (rl *RouteLoads) Cleanup()
func (*RouteLoads) TaskCount ¶ added in v0.1.22
func (rl *RouteLoads) TaskCount() int16
func (*RouteLoads) TaskRunningCount ¶ added in v0.1.22
func (rl *RouteLoads) TaskRunningCount() int16
type SpeedCountWriter ¶ added in v0.1.11
type SpeedCountWriter struct {
// contains filtered or unexported fields
}
func (*SpeedCountWriter) CostTime ¶ added in v0.1.11
func (w *SpeedCountWriter) CostTime() float64
ms
func (*SpeedCountWriter) Header ¶ added in v0.1.11
func (w *SpeedCountWriter) Header() http.Header
func (*SpeedCountWriter) PeakSpeed ¶ added in v0.1.22
func (w *SpeedCountWriter) PeakSpeed() int64
func (*SpeedCountWriter) Speed ¶ added in v0.1.22
func (w *SpeedCountWriter) Speed() int64
func (*SpeedCountWriter) Write ¶ added in v0.1.11
func (w *SpeedCountWriter) Write(bytes []byte) (int, error)
func (*SpeedCountWriter) WriteHeader ¶ added in v0.1.11
func (w *SpeedCountWriter) WriteHeader(statusCode int)
type StatsRaw ¶ added in v0.1.22
type StatsRaw struct {
Peak0 FlowUnit
Peak1 FlowUnit
Peak2 FlowUnit
Current FlowUnit
Loads [Peak1WindowSize]FlowUnit
Routes *RouteLoads
}
type Validation ¶
type Validation interface {
SetFunc(func() string)
}
Source Files
¶
- asset.go
- blockstore.go
- getter.go
- handler.go
- handler_block.go
- handler_car.go
- handler_cid_list.go
- handler_codec.go
- handler_get.go
- handler_head.go
- handler_monitor.go
- handler_tar.go
- handler_unixfs.go
- handler_unixfs_dir.go
- handler_unixfs_file.go
- handler_upload.go
- handler_uploadv2.go
- handler_uploadv3.go
- handler_uploadv4.go
- httpserver.go
- lazy_seeker.go
- progress_reader.go
- speedCountWriter.go
Click to show internal directories.
Click to hide internal directories.