Documentation
¶
Index ¶
- func Manifold(cfg ManifoldConfig) dependency.Manifold
- func NewAsyncDownloadWorker(appID application.ID, applicationService ApplicationService, ...) worker.Worker
- func NewHTTPClient(ctx context.Context, getter corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
- type ApplicationService
- type Config
- type Downloader
- type ManifoldConfig
- type NewAsyncDownloadWorkerFunc
- type NewDownloaderFunc
- type NewHTTPClientFunc
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(cfg ManifoldConfig) dependency.Manifold
Manifold returns a Manifold that encapsulates the charmdownloader worker.
func NewAsyncDownloadWorker ¶
func NewAsyncDownloadWorker( appID application.ID, applicationService ApplicationService, downloader Downloader, clock clock.Clock, logger logger.Logger, ) worker.Worker
NewAsyncDownloadWorker creates a new async worker that downloads charms for the specified application.
func NewHTTPClient ¶
func NewHTTPClient(ctx context.Context, getter corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
NewHTTPClient creates a new HTTP client.
Types ¶
type ApplicationService ¶
type ApplicationService interface { // WatchApplicationsWithPendingCharms returns a watcher that notifies of // changes to applications that reference charms that have not yet been // downloaded. // Each string will be an individual application ID. It's possible to // have the same application ID multiple times in the list. WatchApplicationsWithPendingCharms(ctx context.Context) (watcher.StringsWatcher, error) // GetAsyncCharmDownloadInfo reserves a charm download slot for the specified // application. If the charm is already being downloaded, the method will // return [applicationerrors.AlreadyDownloadingCharm]. The charm download // information is returned which includes the charm name, origin and the // digest. GetAsyncCharmDownloadInfo(ctx context.Context, appID application.ID) (domainapplication.CharmDownloadInfo, error) // ResolveCharmDownload resolves the charm download slot for the specified // application. The method will update the charm with the specified charm // information. ResolveCharmDownload(ctx context.Context, appID application.ID, resolve domainapplication.ResolveCharmDownload) error }
ApplicationService describes the API exposed by the charm downloader facade.
type Config ¶
type Config struct { ApplicationService ApplicationService HTTPClientGetter corehttp.HTTPClientGetter NewHTTPClient NewHTTPClientFunc NewDownloader NewDownloaderFunc NewAsyncDownloadWorker NewAsyncDownloadWorkerFunc Logger logger.Logger Clock clock.Clock }
Config defines the operation of a Worker.
type Downloader ¶
type Downloader interface { // Download looks up the requested charm using the appropriate store, downloads // it to a temporary file and passes it to the configured storage API so it can // be persisted. // // The resulting charm is verified to be the right hash. It expected that the // origin will always have the correct hash following this call. // // Returns [ErrInvalidHash] if the hash of the downloaded charm does not match // the expected hash. Download(ctx context.Context, curl *url.URL, hash string) (*charmdownloader.DownloadResult, error) }
Downloader is responsible for downloading charms from the charm store.
func NewDownloader ¶
func NewDownloader(httpClient charmhub.HTTPClient, logger logger.Logger) Downloader
NewDownloader creates a new Downloader instance.
type ManifoldConfig ¶
type ManifoldConfig struct { DomainServicesName string HTTPClientName string NewDownloader NewDownloaderFunc NewHTTPClient NewHTTPClientFunc NewAsyncDownloadWorker NewAsyncDownloadWorkerFunc Logger logger.Logger Clock clock.Clock }
ManifoldConfig describes the resources used by the charmdownloader worker.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
Validate is called by start to check for bad configuration.
type NewAsyncDownloadWorkerFunc ¶
type NewAsyncDownloadWorkerFunc func( appID application.ID, applicationService ApplicationService, downloader Downloader, clock clock.Clock, logger logger.Logger, ) worker.Worker
NewAsyncDownloadWorkerFunc is a function that creates a new async worker.
type NewDownloaderFunc ¶
type NewDownloaderFunc func(charmhub.HTTPClient, logger.Logger) Downloader
NewDownloaderFunc is a function that creates a new Downloader.
type NewHTTPClientFunc ¶
type NewHTTPClientFunc func(context.Context, corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
NewHTTPClientFunc is a function that creates a new HTTP client.