Documentation
¶
Index ¶
- Constants
- func NewHttpIpfsHandlerFunc(ctx context.Context, lsys linking.LinkSystem, opts ...HttpOption) http.HandlerFunc
- func StreamCar(ctx context.Context, requestLsys linking.LinkSystem, out io.Writer, ...) error
- type ErrorLogger
- type FrisbiiServer
- type HttpIpfs
- type HttpOption
- type IndexerProvider
- type LogHandler
- type LogMiddleware
- type LoggingResponseWriter
- func (w *LoggingResponseWriter) CompressionRatio() string
- func (w *LoggingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *LoggingResponseWriter) Log(status int, start time.Time, bytes int, CompressionRatio string, msg string)
- func (w *LoggingResponseWriter) LogError(status int, err error)
- func (w *LoggingResponseWriter) Write(b []byte) (int, error)
- func (w *LoggingResponseWriter) WriteHeader(status int)
- func (w *LoggingResponseWriter) WroteBytes(n int)
- type MultiReadableStorage
- func (m *MultiReadableStorage) AddStore(store storage.StreamingReadableStorage, roots []cid.Cid)
- func (m *MultiReadableStorage) Get(ctx context.Context, key string) ([]byte, error)
- func (m *MultiReadableStorage) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (m *MultiReadableStorage) Has(ctx context.Context, key string) (bool, error)
- func (m *MultiReadableStorage) RootsLister() provider.MultihashLister
Constants ¶
const ContextID = "frisbii"
Variables ¶
This section is empty.
Functions ¶
func NewHttpIpfsHandlerFunc ¶ added in v0.3.0
func NewHttpIpfsHandlerFunc( ctx context.Context, lsys linking.LinkSystem, opts ...HttpOption, ) http.HandlerFunc
Types ¶
type ErrorLogger ¶
type FrisbiiServer ¶
type FrisbiiServer struct {
// contains filtered or unexported fields
}
FrisbiiServer is the main server for the frisbii application, it starts an HTTP server to serve data according to the Trustless Gateway spec and it also provides a mechanism to announce the server to the indexer service.
func NewFrisbiiServer ¶
func NewFrisbiiServer( ctx context.Context, lsys linking.LinkSystem, address string, httpOptions ...HttpOption, ) (*FrisbiiServer, error)
func (*FrisbiiServer) Addr ¶
func (fs *FrisbiiServer) Addr() net.Addr
func (*FrisbiiServer) Announce ¶
func (fs *FrisbiiServer) Announce() error
func (*FrisbiiServer) Serve ¶
func (fs *FrisbiiServer) Serve() error
func (*FrisbiiServer) SetIndexerProvider ¶
func (fs *FrisbiiServer) SetIndexerProvider(handlerPath string, indexerProvider IndexerProvider) error
type HttpIpfs ¶
type HttpIpfs struct {
// contains filtered or unexported fields
}
HttpIpfs is an http.Handler that serves IPLD data via HTTP according to the Trustless Gateway specification.
func NewHttpIpfs ¶
func NewHttpIpfs( ctx context.Context, lsys linking.LinkSystem, opts ...HttpOption, ) *HttpIpfs
NewHttpIpfs returns an http.Handler that serves IPLD data via HTTP according to the Trustless Gateway specification.
type HttpOption ¶ added in v0.1.0
type HttpOption func(*httpOptions)
func WithCompressionLevel ¶ added in v0.3.0
func WithCompressionLevel(l int) HttpOption
WithCompressionLevel sets the compression level for the gzip compression applied to the response. This allows for a trade-off between CPU and bandwidth. By default, the compression level is set to gzip.NoCompression; which means compression will be disabled.
Other recommended choices are gzip.BestSpeed (1), gzip.BestCompression (9), and gzip.DefaultCompression (typically 6).
func WithLogHandler ¶ added in v0.4.0
func WithLogHandler(h LogHandler) HttpOption
WithLogHandler sets a handler function that will be used to log requests. By default, requests are not logged. This is an alternative to WithLogWriter that allows for more control over the logging.
func WithLogWriter ¶ added in v0.4.0
func WithLogWriter(w io.Writer) HttpOption
WithLogWriter sets the writer that will be used to log requests. By default, requests are not logged.
The log format for requests (including errors) is roughly equivalent to a standard nginx or Apache log format; that is, a space-separated list of elements, where the elements that may contain spaces are quoted. The format of each line can be specified as:
%s %s %s "%s" %d %d %d %s "%s" "%s"
Where the elements are:
1. RFC 3339 timestamp 2. Remote address 3. Method 4. Path 5. Response status code 6. Response duration (in milliseconds) 7. Response size 8. Compression ratio (or `-` if no compression) 9. User agent 10. Error (or `""` if no error)
func WithMaxResponseBytes ¶ added in v0.1.0
func WithMaxResponseBytes(b int64) HttpOption
WithMaxResponseBytes sets the maximum number of bytes that will be streamed before the connection is closed. This allows a server to limit the amount of data a client can request; and also restricts the ability to serve very large DAGs.
A value of 0 will disable the limitation. This is the default.
func WithMaxResponseDuration ¶ added in v0.1.0
func WithMaxResponseDuration(d time.Duration) HttpOption
WithMaxResponseDuration sets the maximum duration for a response to be streamed before the connection is closed. This allows a server to limit the amount of time a client can hold a connection open; and also restricts the ability to serve very large DAGs.
A value of 0 will disable the limitation. This is the default.
type IndexerProvider ¶
type LogHandler ¶ added in v0.4.0
type LogMiddleware ¶
type LogMiddleware struct {
// contains filtered or unexported fields
}
LogMiddlware is a middleware that logs requests to the given io.Writer. it wraps requests in a LoggingResponseWriter that can be used to log standardised messages to the writer.
func NewLogMiddleware ¶
func NewLogMiddleware(next http.Handler, httpOptions ...HttpOption) *LogMiddleware
NewLogMiddleware creates a new LogMiddleware to insert into an HTTP call chain.
The WithLogWriter option can be used to set the writer to log to.
The WithLogHandler option can be used to set a custom log handler.
func (*LogMiddleware) ServeHTTP ¶
func (lm *LogMiddleware) ServeHTTP(res http.ResponseWriter, req *http.Request)
type LoggingResponseWriter ¶
type LoggingResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func NewLoggingResponseWriter ¶
func NewLoggingResponseWriter( w http.ResponseWriter, req *http.Request, logWriter io.Writer, logHandler LogHandler, ) *LoggingResponseWriter
NewLoggingResponseWriter creates a new LoggingResponseWriter that is used on a per-request basis to log information about the request.
func (*LoggingResponseWriter) CompressionRatio ¶ added in v0.3.0
func (w *LoggingResponseWriter) CompressionRatio() string
func (*LoggingResponseWriter) Hijack ¶
func (w *LoggingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*LoggingResponseWriter) LogError ¶
func (w *LoggingResponseWriter) LogError(status int, err error)
func (*LoggingResponseWriter) WriteHeader ¶
func (w *LoggingResponseWriter) WriteHeader(status int)
func (*LoggingResponseWriter) WroteBytes ¶ added in v0.4.0
func (w *LoggingResponseWriter) WroteBytes(n int)
WroteBytes can be called by the base writer, on each Write call, to indicate how many bytes were written in to the response. If LoggingResponseWriter is wrapping a compression writer, this should be the number of bytes written to the compression writer, which will be different than the number of bytes written to this writer; hence we can calculate the compression ratio.
type MultiReadableStorage ¶
type MultiReadableStorage struct {
// contains filtered or unexported fields
}
MultiReadableStorage manages a list of storage.StreamingReadableStorage stores, providing a unified LinkSystem interface to them.
func NewMultiReadableStorage ¶
func NewMultiReadableStorage() *MultiReadableStorage
func (*MultiReadableStorage) AddStore ¶
func (m *MultiReadableStorage) AddStore(store storage.StreamingReadableStorage, roots []cid.Cid)
func (*MultiReadableStorage) GetStream ¶
func (m *MultiReadableStorage) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
func (*MultiReadableStorage) RootsLister ¶
func (m *MultiReadableStorage) RootsLister() provider.MultihashLister