Documentation
¶
Index ¶
- Constants
- Variables
- type Authentication
- type BaseCacheListener
- func (BaseCacheListener) AfterFetch(registry, pkg, version string, err error)
- func (BaseCacheListener) BeforeFetch(registry, pkg, version string)
- func (BaseCacheListener) OnCacheHit(registry, pkg, version string)
- func (BaseCacheListener) OnDelete(registry, pkg, version string)
- func (BaseCacheListener) OnFetch(registry, pkg, version string, size int64)
- func (BaseCacheListener) OnFetchWrite(registry, pkg, version string, bytes []byte)
- func (BaseCacheListener) OnUnpack(registry, pkg, version, file string, size int64)
- func (BaseCacheListener) OnUnpackWrite(registry, pkg, version, file string, bytes []byte)
- type Cache
- func (c *Cache) AddClient(registry string, client *Client)
- func (c *Cache) AddListener(listener CacheListener)
- func (c *Cache) AddLocalPackage(pkg, version, path string)
- func (c *Cache) CacheDir(registry, pkg, version string) string
- func (c *Cache) Contains(registry, pkg, version string) bool
- func (c *Cache) Delete(registry, pkg, version string) error
- func (c *Cache) Fetch(ctx context.Context, registry, pkg, version string) error
- func (c *Cache) ForceFetch(ctx context.Context, registry, pkg, version string) error
- func (c *Cache) Get(registry, pkg, version string) (*Package, error)
- func (c *Cache) GetOrFetch(ctx context.Context, registry, pkg, version string) (*Package, error)
- func (c *Cache) Root() string
- type CacheListener
- type Client
- type Downloader
- type Listeners
- func (l Listeners) AfterFetch(registry, pkg, version string, err error)
- func (l Listeners) BeforeFetch(registry, pkg, version string)
- func (l Listeners) OnCacheHit(registry, pkg, version string)
- func (l Listeners) OnDelete(registry, pkg, version string)
- func (l Listeners) OnFetch(registry, pkg, version string, size int64)
- func (l Listeners) OnFetchWrite(registry, pkg, version string, bytes []byte)
- func (l Listeners) OnUnpack(registry, pkg, version, file string, size int64)
- func (l Listeners) OnUnpackWrite(registry, pkg, version, file string, bytes []byte)
- type Option
- type Package
- type PackageManifest
- type PackageRef
Constants ¶
const ( Local = "local" Default = "default" )
Variables ¶
var ( ErrStatusCode = fmt.Errorf("unexpected status code") ErrNoTarball = fmt.Errorf("missing tarball URL") ErrBadContentType = fmt.Errorf("unexpected content-type") ErrBadContent = fmt.Errorf("bad content") )
var DefaultClient = &Client{ client: http.DefaultClient, url: "https://packages.simplifier.net", }
DefaultClient returns a new registry client with the default simplifier registry configured, using a non-authenticated client.
Functions ¶
This section is empty.
Types ¶
type Authentication ¶
type Authentication = auth.Authentication
Authentication is an interface for providing oauth2 authentication to the registry.
func NoAuthentication ¶
func NoAuthentication() Authentication
NoAuthentication returns an Authentication option that provides no real authentication. This is the default behavior if no authentication is specified.
func StaticTokenSource ¶
func StaticTokenSource(token string) Authentication
StaticTokenSource returns an Authentication that always returns the same token.
func TokenSource ¶
func TokenSource(ts oauth2.TokenSource) Authentication
StaticTokenSource returns an Authentication that always returns the same token.
type BaseCacheListener ¶
type BaseCacheListener struct{}
BaseCacheListener is a base implementation of the CacheListener interface.
func (BaseCacheListener) AfterFetch ¶
func (BaseCacheListener) AfterFetch(registry, pkg, version string, err error)
AfterFetch is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) BeforeFetch ¶
func (BaseCacheListener) BeforeFetch(registry, pkg, version string)
BeforeFetch is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnCacheHit ¶
func (BaseCacheListener) OnCacheHit(registry, pkg, version string)
OnCacheHit is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnDelete ¶
func (BaseCacheListener) OnDelete(registry, pkg, version string)
OnDelete is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnFetch ¶
func (BaseCacheListener) OnFetch(registry, pkg, version string, size int64)
OnFetch is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnFetchWrite ¶
func (BaseCacheListener) OnFetchWrite(registry, pkg, version string, bytes []byte)
OnFetchWrite is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnUnpack ¶
func (BaseCacheListener) OnUnpack(registry, pkg, version, file string, size int64)
OnUnpack is a no-op implementation of the CacheListener interface.
func (BaseCacheListener) OnUnpackWrite ¶
func (BaseCacheListener) OnUnpackWrite(registry, pkg, version, file string, bytes []byte)
OnUnpackWrite is a no-op implementation of the CacheListener interface.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a cache of downloaded and used FHIR packages from a given registry.
func DefaultCache ¶
func DefaultCache() *Cache
DefaultCache creates a new cache with the default output path. The behavior can be controlled with the presence of the FHIR_CACHE environment variable.
func (*Cache) AddListener ¶
func (c *Cache) AddListener(listener CacheListener)
AddListener adds a listener to the cache.
func (*Cache) AddLocalPackage ¶
AddLocalPackage adds a local package to the cache that may be referenced later. The package registry is always considered "local".
func (*Cache) CacheDir ¶
CacheDir returns the directory where the specified package is cached. If the registry is unknown, or if any parameters are not set, an empty string is returned.
func (*Cache) Contains ¶
Contains returns true if the cache contains the specified package. Containment does not imply that the package is valid or usable -- just that the contents can be found on disk.
func (*Cache) ForceFetch ¶
ForceFetch forces a download of the specified package from the registry.
func (*Cache) GetOrFetch ¶
GetOrFetch returns the package from the cache, or fetches it if it is not present.
type CacheListener ¶
type CacheListener interface {
// BeforeFetch is an event handler invoked before a fetch operation is initiated.
BeforeFetch(registry, pkg, version string)
// OnFetch is an event handler invoked when a fetch operation is initiated.
OnFetch(registry, pkg, version string, size int64)
// OnFetchWrite is an event handler invoked when bytes written during a fetch
// operation.
OnFetchWrite(registry, pkg, version string, bytes []byte)
// AfterFetch is an event handler invoked after a fetch operation is completed.
AfterFetch(registry, pkg, version string, err error)
// OnUnpack is an event handler invoked when a file is unpacked.
OnUnpack(registry, pkg, version, file string, size int64)
// OnUnpackWrite is an event handler invoked when bytes written during a
// file unpack operation.
OnUnpackWrite(registry, pkg, version, file string, bytes []byte)
// OnDelete is an event handler invoked when a package is deleted from the
// cache.
OnDelete(registry, pkg, version string)
// OnCacheHit is an event handler invoked when a cache hit occurs.
OnCacheHit(registry, pkg, version string)
// contains filtered or unexported methods
}
CacheListener is a listener for events occurring when populating the cache.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a registry client for accessing packages from the registry.
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader is a utility for downloading packages and their dependencies into the Cache.
func NewDownloader ¶
func NewDownloader(dest *Cache) *Downloader
NewDownloader creates a new Downloader.
func (*Downloader) Add ¶
func (d *Downloader) Add(registry, pkg, version string, includeDependencies bool)
Add an explicit package to download from the registry. If includeDependencies is set to true, the downloader will also download the dependencies for the package.
func (*Downloader) Force ¶
func (d *Downloader) Force(b bool) *Downloader
Force forces the downloader to fetch the package from the registry, even if it is already present in the cache.
func (*Downloader) Start ¶
func (d *Downloader) Start(ctx context.Context) error
Start the download process which will load the cache with the downloaded packages and their dependencies.
This function will block until all worker threads have completed downloading the packages and their dependencies. If an error occurs during the download process, the function will return the first encountered error.
func (*Downloader) Workers ¶
func (d *Downloader) Workers(n int) *Downloader
Workers sets the number of worker threads. If it is less than 1, the number of worker threads will be set to the number of CPUs on the system.
type Listeners ¶
type Listeners []CacheListener
Listeners is a collection of [CacheListener]s that itself can be treated as a single listener.
func (Listeners) AfterFetch ¶
AfterFetch is an event handler invoked after a fetch operation is completed.
func (Listeners) BeforeFetch ¶
BeforeFetch is an event handler invoked before a fetch operation is initiated.
func (Listeners) OnCacheHit ¶
OnCacheHit is an event handler invoked when a cache hit occurs.
func (Listeners) OnDelete ¶
OnDelete is an event handler invoked when a package is deleted from the cache.
func (Listeners) OnFetchWrite ¶
OnFetchWrite is an event handler invoked when bytes written during a fetch operation.
func (Listeners) OnUnpackWrite ¶
OnUnpackWrite is an event handler invoked when bytes written during a file unpack operation.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func Auth ¶
func Auth(auth Authentication) Option
Auth returns an Option that sets the authentication method for the client.
type Package ¶
type Package struct {
// Path to the location on-disk where the registry has been unpacked to.
Path string
// Manifest is the package manifest.
Manifest *PackageManifest
// Ref is the reference to the package.
Ref PackageRef
}
Package represents a FHIR package that has been unpacked on-disk.
func NewPackage ¶
NewPackage creates a new package from the content at the specified file path. The path must contain a package.json content that defines information about the FHIR package.
func (*Package) Dependencies ¶
Dependencies returns the dependencies for the package.
func (*Package) FHIRVersionList ¶
FHIRVersionList returns the list of FHIR versions supported by the package.
type PackageManifest ¶
type PackageManifest struct {
Name string `json:"name"`
Version string `json:"version"`
FHIRVersionList []string `json:"fhir-version-list,omitempty"`
Type string `json:"type"`
Dependencies map[string]string `json:"dependencies"`
License string `json:"license"`
Title string `json:"title"`
Description string `json:"description"`
Author string `json:"author"`
URL string `json:"url"`
ToolsVersion int `json:"tools-version"`
Canonical string `json:"canonical"`
Homepage string `json:"homepage"`
}
PackageManifest represents the manifest of a package, in NPM package.json format.
type PackageRef ¶
type PackageRef string
PackageRef is a string that is always in the form of <registry>::<package>@<version>. This is intended for easily passing along package references to other utilities that need this data in some structured manner.
func NewPackageRef ¶
func NewPackageRef(registry, name, version string) PackageRef
func (PackageRef) Name ¶
func (p PackageRef) Name() string
Name returns the name of the package reference.
func (PackageRef) Parts ¶
func (p PackageRef) Parts() (registry, name, version string)
Parts returns the registry, name, and version of the package reference.
func (PackageRef) Registry ¶
func (p PackageRef) Registry() string
Registry returns the registry of the package reference.
func (PackageRef) String ¶
func (p PackageRef) String() string
String returns the string representation of the package reference.
func (PackageRef) Version ¶
func (p PackageRef) Version() string
Version returns the version of the package reference.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package registrytest provides test-doubles and fakes for the [registry.Client] and other related types.
|
Package registrytest provides test-doubles and fakes for the [registry.Client] and other related types. |