services

package
v0.0.0-...-4181ed6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disco

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

Disco service allows us to do Disco things on top of the Distribution server.

func NewDiscoService

func NewDiscoService() *Disco

NewDiscoService creates a new Disco service.

func (*Disco) CloneGlobalRepo

func (disco *Disco) CloneGlobalRepo(ctx context.Context, repoName string) error

CloneGlobalRepo clones the repo from IPFS network to the IPFS node. Steps in here are executed before Distribution server tries to locate a repository:

  1. Check if the repo name is base32 CID v1. If not, leave the rest to the Distribution server.
  2. Copy the repo files from IPFS network to the IPFS node's MFS.
  3. Use disco.json inside the repo files to copy the blobs over the network.

The end result in the IPFS node's MFS should look like the one from MakeGlobalRepo and all CIDs should match.

func (*Disco) IsOnlyPullable

func (disco *Disco) IsOnlyPullable(repoName string) bool

IsOnlyPullable tells if the repo is name of a pullable-only repo name.

func (*Disco) MakeGlobalRepo

func (disco *Disco) MakeGlobalRepo(ctx context.Context, repoName string) error

MakeGlobalRepo makes the repo a globally addressable one. We achieve this by benefiting from the content addressing and data deduplication properties of IPFS.

This makes Disco a huge bucket of repositories which are identifiable only by hashes and each repository only has the version "latest".

Steps in here are executed after Distribution server creates a repository:

  1. Add disco.json to the repo dir so the blobs can be copied from the network at the time of "pull".
  2. Duplicate the repo by using the base32-encoded IPFS CID of repo dir as the repo name so it becomes very easy to address the repo.
  3. Duplicate the repo by using the manifest digest as the repo name so we make <digest>:latest possible.
  4. Tag the repo in step 3 with the name in step 2 like <digest>:<CID> so it becomes easy to discover the CID from the digest.
  5. Remove the repo which was created before step 1 so we allow no special names for repositories.

The images should be accessible from any Disco which speaks to an IPFS node connected to the network. Duplicating repositories in IPFS MFS with different names shouldn't cause IPFS to duplicate the actual files.

After pushing <disco_host>:1970/myrepo, it transforms the storage from:

	/myrepo - QmWhatever1
   ..
     /tags
       /latest

to:

/<cidv1(QmWhatever2)> - QmWhatever2
  disco.json
  ..
    /tags
      /latest
/<digest> - QmWhatever3
  disco.json
  ..
    /tags
      /latest
      /<cidv1(QmWhatever2)>

Jump to

Keyboard shortcuts

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