Documentation
¶
Overview ¶
IPFS-DaemonLauncher is a package that manages running an IPFS node in the background and offers a user-friendly interface, enabling you to build IPFS-embedded Golang applications more efficiently.
Index ¶
- Constants
- type IpfsDaemonLauncher
- func (wrap *IpfsDaemonLauncher) AddFile(ctx context.Context, filepath string) (string, error)
- func (wrap *IpfsDaemonLauncher) AddFileContent(ctx context.Context, filename string, fileContent []byte) (string, error)
- func (wrap *IpfsDaemonLauncher) Cat(ctx context.Context, cid string) ([]byte, error)
- func (wrap *IpfsDaemonLauncher) ForceShutdownDaemon() error
- func (wrap *IpfsDaemonLauncher) GarbageCollection(ctx context.Context) error
- func (wrap *IpfsDaemonLauncher) GetFile(ctx context.Context, cid string) error
- func (wrap *IpfsDaemonLauncher) ListPins(ctx context.Context) ([]string, error)
- func (wrap *IpfsDaemonLauncher) ListPinsByType(ctx context.Context, typeID string) ([]string, error)
- func (wrap *IpfsDaemonLauncher) Pin(ctx context.Context, cid string) error
- func (wrap *IpfsDaemonLauncher) ShutdownDaemon() error
- func (wrap *IpfsDaemonLauncher) StartDaemonInBackground() error
- func (wrap *IpfsDaemonLauncher) Unpin(ctx context.Context, cid string) error
- type Option
- func WithContinousOperation() Option
- func WithDenylist(denylistFilename string, denylistURL string) Option
- func WithForcedShutdownDaemonOnStartup() Option
- func WithOverrideBinaryOsAndArch(overrideOS, overrideArch string) Option
- func WithOverrideDaemonInitialWarmupDuration(seconds int) Option
- func WithRunGarbageCollectionOnStarup() Option
Constants ¶
const ( IPFSBinaryFilePath = "./bin/kubo/ipfs" IPFSDataDirPath = "./bin/kubo/data" IPFSDenylistDirPath = IPFSDataDirPath + "/denylists/" )
const ( AllPinType = "all" RecursivePinType = "recursive" IndirectPinType = "indirect" DirectPinType = "direct" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IpfsDaemonLauncher ¶
type IpfsDaemonLauncher struct {
// contains filtered or unexported fields
}
IpfsDaemonLauncher represents the a wrapper over a `ipfs` executable binary in the operating system that we use to control the operation of.
func NewDaemonLauncher ¶
func NewDaemonLauncher(options ...Option) (*IpfsDaemonLauncher, error)
func (*IpfsDaemonLauncher) AddFileContent ¶
func (*IpfsDaemonLauncher) ForceShutdownDaemon ¶
func (wrap *IpfsDaemonLauncher) ForceShutdownDaemon() error
ForceShutdownDaemon function will send KILL signal to the operating system for the `ipfs` running daemon in background to force that binary to shutdown.
func (*IpfsDaemonLauncher) GarbageCollection ¶
func (wrap *IpfsDaemonLauncher) GarbageCollection(ctx context.Context) error
func (*IpfsDaemonLauncher) GetFile ¶
func (wrap *IpfsDaemonLauncher) GetFile(ctx context.Context, cid string) error
func (*IpfsDaemonLauncher) ListPins ¶
func (wrap *IpfsDaemonLauncher) ListPins(ctx context.Context) ([]string, error)
func (*IpfsDaemonLauncher) ListPinsByType ¶
func (*IpfsDaemonLauncher) Pin ¶
func (wrap *IpfsDaemonLauncher) Pin(ctx context.Context, cid string) error
func (*IpfsDaemonLauncher) ShutdownDaemon ¶
func (wrap *IpfsDaemonLauncher) ShutdownDaemon() error
func (*IpfsDaemonLauncher) StartDaemonInBackground ¶
func (wrap *IpfsDaemonLauncher) StartDaemonInBackground() error
type Option ¶
type Option func(*IpfsDaemonLauncher)
Option is a functional option type that allows us to configure the IpfsDaemonLauncher.
func WithContinousOperation ¶
func WithContinousOperation() Option
WithContinousOperation is a functional option to configure our wrapper to not terminate the operation of the `ipfs` binary when running in the background; in addition when we run the `Start()` function, no errors will occure pertaining to previously active running `ipfs` binary instance. This is a useful option if you developing an app in which you restart often and you don't want to restart the `ipfs` binary often then use this option.
func WithDenylist ¶
WithDenylist is a functional option which downloads a `denylist` [0] from the URL you provided and applies it to the `ipfs` binary running instance. [0] https://github.com/ipfs/kubo/blob/master/docs/content-blocking.md
func WithForcedShutdownDaemonOnStartup ¶
func WithForcedShutdownDaemonOnStartup() Option
WithForcedShutdownDaemonOnStartup is a functional option to add if you want this package to look for any previously running `ipfs` binary in the system background and shut it down before our package loads up a new `ipfs` binary instance.
func WithOverrideBinaryOsAndArch ¶
WithOverrideBinaryOsAndArch is a functional option to configure our wrapper to use a specific binary. The available `os` options are: darwin, linux, freebsd, openbsd and windows. The available `arch` choices are: arm, arm64, 386, and amd64.
func WithOverrideDaemonInitialWarmupDuration ¶
WithOverrideDaemonInitialWarmupDuration is a functional option to configure our wrapper to set a custom warmup delay for our app to give a custom delay to allow the `ipfs` to loadup before giving your app execution control.
func WithRunGarbageCollectionOnStarup ¶
func WithRunGarbageCollectionOnStarup() Option