commands

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	ConfigRoot string
	ReqLog     *ReqLog

	Plugins *loader.PluginLoader

	Gateway bool

	ConstructNode func() (*core.IpfsNode, error)
	// contains filtered or unexported fields
}

Context represents request context.

func (*Context) ClearCachedNode added in v0.37.0

func (c *Context) ClearCachedNode()

ClearCachedNode clears any cached node, forcing GetNode to construct a new one.

This method is critical for mitigating racy FX dependency injection behavior that can occur during daemon startup. The daemon may create multiple IpfsNode instances during initialization - first an offline node during early init, then the proper online daemon node. Without clearing the cache, HTTP RPC handlers may end up using the first (offline) cached node instead of the intended online daemon node.

This behavior was likely present forever in go-ipfs, but recent changes made it more prominent and forced us to proactively mitigate FX shortcomings. The daemon calls this method immediately before setting its ConstructNode function to ensure that subsequent GetNode() calls use the correct online daemon node rather than any stale cached offline node from initialization.

func (*Context) Close added in v0.4.14

func (c *Context) Close()

Close cleans up the application state.

func (*Context) Context

func (c *Context) Context() context.Context

Context returns the node's context.

func (*Context) GetAPI added in v0.4.19

func (c *Context) GetAPI() (coreiface.CoreAPI, error)

GetAPI returns CoreAPI instance backed by ipfs node. It may construct the node with the provided function.

func (*Context) GetConfig

func (c *Context) GetConfig() (*config.Config, error)

func (*Context) GetNode

func (c *Context) GetNode() (*core.IpfsNode, error)

GetNode returns the node of the current Command execution context. It may construct it with the provided function.

func (*Context) LogRequest added in v0.4.14

func (c *Context) LogRequest(req *cmds.Request) func()

LogRequest adds the passed request to the request log and returns a function that should be called when the request lifetime is over.

type ReqLog added in v0.4.0

type ReqLog struct {
	Requests []*ReqLogEntry
	// contains filtered or unexported fields
}

ReqLog is a log of requests.

func (*ReqLog) AddEntry added in v0.4.14

func (rl *ReqLog) AddEntry(rle *ReqLogEntry)

AddEntry adds an entry to the log.

func (*ReqLog) ClearInactive added in v0.4.0

func (rl *ReqLog) ClearInactive()

ClearInactive removes stale entries.

func (*ReqLog) Finish added in v0.4.14

func (rl *ReqLog) Finish(rle *ReqLogEntry)

Finish marks an entry in the log as finished.

func (*ReqLog) Report added in v0.4.0

func (rl *ReqLog) Report() []*ReqLogEntry

Report generates a copy of all the entries in the requestlog.

func (*ReqLog) SetKeepTime added in v0.4.0

func (rl *ReqLog) SetKeepTime(t time.Duration)

SetKeepTime sets a duration after which an entry will be considered inactive.

type ReqLogEntry added in v0.4.0

type ReqLogEntry struct {
	StartTime time.Time
	EndTime   time.Time
	Active    bool
	Command   string
	Options   map[string]interface{}
	Args      []string
	ID        int
	// contains filtered or unexported fields
}

ReqLogEntry is an entry in the request log.

func (*ReqLogEntry) Copy added in v0.4.0

func (r *ReqLogEntry) Copy() *ReqLogEntry

Copy returns a copy of the ReqLogEntry.

Jump to

Keyboard shortcuts

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