registry

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: BSD-2-Clause, Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTimeString

func GetTimeString(d time.Duration) string

GetTimeString returns a string-encoded time.Duration.

func Logging

func Logging(next http.Handler) http.Handler

Logging returns a handler function for serving.

Types

type Artifact

type Artifact struct {
	ID       string
	Filepath string
	Created  time.Time
	Size     int64
}

Artifact represents something to be added to a repo according to tags.

type Registry

type Registry interface {
	GetArtifact(repo, tag string) (*Artifact, error)           // use (nil, nil) return for "not found" or nonexistent. reserve errors for connection errors or similar (i.e.  "this record might exist, but I can say for sure right now")
	PutArtifact(repo string, tags []string, data []byte) error //

	Save(save_path string) error // We require these, b/c the service needs to be reloadable for now
	Load(load_path string) error // ""

	// Hierarchical API Repos have tags which have artifacts
	Repos() []string
	Tags(repo string) []string
	Artifacts(repo, tag string) []string
}

Registry bundles tools for maintaining a core registry of agents. For now, only .tar.gz files are supported.

type RegistryServer

type RegistryServer struct {
	Registry
	// contains filtered or unexported fields
}

RegistryServer hosts an embedded Registry object.

func NewRegistryServer

func NewRegistryServer(addr, data_root string) *RegistryServer

NewRegistryServer creates a new RegistryServer for a specified address and data root.

func (*RegistryServer) AgentListHandler

func (rs *RegistryServer) AgentListHandler(w http.ResponseWriter, r *http.Request)

AgentListHandler is a handler function for the /list endpoint.

func (*RegistryServer) GetHandler

func (rs *RegistryServer) GetHandler(w http.ResponseWriter, r *http.Request)

GetHandler is a GET handler function for the /{repo} endpoint.

func (*RegistryServer) ListenAndServe

func (r *RegistryServer) ListenAndServe() error

ListenAndServe listens on the network at a specified address for the RegistryServer.

func (*RegistryServer) PutHandler

func (rs *RegistryServer) PutHandler(w http.ResponseWriter, r *http.Request)

GetHandler is a PUT handler function for the /{repo} endpoint.

func (*RegistryServer) Shutdown

func (r *RegistryServer) Shutdown() error

Shutdown gracefully shuts down a registry server.

type SimpleHistory

type SimpleHistory struct {
	History map[string][]*Artifact
}

SimpleHistory is a bare-bones implementation of TagHistory for a SimpleRegistry.

func NewSimpleHistory

func NewSimpleHistory() *SimpleHistory

NewSimpleHistory creates an empty SimpleHistory.

func (*SimpleHistory) GetCurrent

func (s *SimpleHistory) GetCurrent(tag string) *Artifact

GetCurrent retrieves the last-added Artifact for a tag in a SimpleHistory.

func (*SimpleHistory) Tags

func (s *SimpleHistory) Tags() []string

Tags lists the tags in a SimpleHistory.

func (*SimpleHistory) Update

func (s *SimpleHistory) Update(tag string, art *Artifact) error

Update adds an incoming Artifact to a SimpleHistory of a specified tag.

type SimpleRegistry

type SimpleRegistry struct {
	DataRoot  string
	CurrRepos map[string]*SimpleHistory // maps repo names to TagHistories
}

SimpleRegistry uses the local filesystem to do basic, safe-ish storage of artifacts. We want to be able to shutdown and restart without issue and that's what it should allow us to do.

Each SimpleRegistry has repos, which are simply just named SimpleHistory objects. Each repo (i.e., SimpleHistory) has many tags, and for each tag, many artifacts.

func NewSimpleRegistry

func NewSimpleRegistry(data_root string) *SimpleRegistry

NewSimpleRegistry creates a new SimpleRegistry for a path to data.

func (*SimpleRegistry) Artifacts

func (s *SimpleRegistry) Artifacts(repo, tag string) []string

Artifacts returns all artifact IDs for a specified repo and tag.

func (*SimpleRegistry) GetArtifact

func (s *SimpleRegistry) GetArtifact(repo_name, tag string) (*Artifact, error)

GetArtifact retrieves the last added Artifact to the specified repo/tag.

func (*SimpleRegistry) Load

func (s *SimpleRegistry) Load(load_path string) error

Load decodes a registry state yaml file.

func (*SimpleRegistry) PutArtifact

func (s *SimpleRegistry) PutArtifact(repo_name string, tags []string, data []byte) error

PutArtifact takes serialized data and injects it into a repo and associated tag.

func (*SimpleRegistry) Repos

func (s *SimpleRegistry) Repos() []string

Repos returns the names of all keys (i.e., repos) in CurrRepos field.

func (*SimpleRegistry) Save

func (s *SimpleRegistry) Save(save_path string) error

Save saves a SimpleRegistry state into a yaml file.

func (*SimpleRegistry) Tags

func (s *SimpleRegistry) Tags(repo string) []string

Tags returns all tags for a specified repo.

type TagHistory

type TagHistory interface {
	GetCurrent(tag string) *Artifact
	Update(tag string, art *Artifact) error
	Tags() []string
}

TagHistory is a list of ids sorted oldest to newest (i.e. the "current" artifact for a tag is history[len(history)-1]).

type WrappedWriter

type WrappedWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

WrappedWriter wraps an http.ResponseWriter for a registry server.

func (*WrappedWriter) WriteHeader

func (w *WrappedWriter) WriteHeader(status_code int)

WriteHeader writes an HTTP response header to the WrappedWriter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳