Documentation
¶
Index ¶
- func NewResourceDownloadLimiter(globalLimit, applicationLimit int) (*resourceDownloadLimiter, error)
- func NewResourceOpenerForApplication(ctx context.Context, args ResourceOpenerArgs, applicationName string) (opener coreresource.Opener, err error)
- func NewResourceOpenerForUnit(ctx context.Context, args ResourceOpenerArgs, ...) (opener coreresource.Opener, err error)
- type ApplicationService
- type DeprecatedState
- type DeprecatedStateApplication
- type DeprecatedStateUnit
- type ModelConfigService
- type ResourceClientGetter
- type ResourceDownloadLock
- type ResourceGetter
- type ResourceOpener
- type ResourceOpenerArgs
- type ResourceService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResourceDownloadLimiter ¶
func NewResourceDownloadLimiter(globalLimit, applicationLimit int) (*resourceDownloadLimiter, error)
NewResourceDownloadLimiter creates a new resource download limiter.
func NewResourceOpenerForApplication ¶
func NewResourceOpenerForApplication( ctx context.Context, args ResourceOpenerArgs, applicationName string, ) (opener coreresource.Opener, err error)
NewResourceOpenerForApplication returns a new resource.Opener for the given app.
The caller owns the State provided. It is the caller's responsibility to close it.
func NewResourceOpenerForUnit ¶
func NewResourceOpenerForUnit( ctx context.Context, args ResourceOpenerArgs, resourceDownloadLimiterFunc func() ResourceDownloadLock, unitName coreunit.Name, ) (opener coreresource.Opener, err error)
NewResourceOpenerForUnit returns a new resource.Opener for the given unit.
The caller owns the State provided. It is the caller's responsibility to close it.
Types ¶
type ApplicationService ¶
type ApplicationService interface { // GetUnitUUID returns the UUID for the named unit. GetUnitUUID(ctx context.Context, unitName coreunit.Name) (coreunit.UUID, error) // GetApplicationIDByUnitName returns the application ID for the named unit. GetApplicationIDByUnitName(ctx context.Context, name coreunit.Name) (coreapplication.ID, error) // GetApplicationIDByName returns an application ID by application name. It // returns an error if the application can not be found by the name. GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error) // GetCharmByApplicationID returns the charm for the specified application // ID. GetCharmByApplicationID(ctx context.Context, id coreapplication.ID) (internalcharm.Charm, domaincharm.CharmLocator, error) }
type DeprecatedState ¶
type DeprecatedState interface { Unit(name string) (DeprecatedStateUnit, error) Application(name string) (DeprecatedStateApplication, error) ModelUUID() string }
DeprecatedState is the deprecated backend soon to be replaced with the resource and application domains.
type DeprecatedStateApplication ¶
type DeprecatedStateApplication interface { CharmOrigin() *state.CharmOrigin CharmURL() (*string, bool) Tag() names.Tag }
DeprecatedStateApplication is the deprecated application state, soon to be replaced with the application domain.
type DeprecatedStateUnit ¶
DeprecatedStateUnit is the deprecated unit state, soon to be replaced with the application domain.
type ModelConfigService ¶
type ModelConfigService interface { // ModelConfig returns the current config for the model. ModelConfig(context.Context) (*config.Config, error) }
ModelConfigService provides access to the model configuration.
type ResourceClientGetter ¶
type ResourceClientGetter interface { // GetResourceClient returns a ResourceGetter. GetResourceClient(ctx context.Context, logger corelogger.Logger) (charmhub.ResourceClient, error) }
ResourceClientGetter gets a client for getting resources.
type ResourceDownloadLock ¶
type ResourceDownloadLock interface { // Acquire grabs the lock for a given application so long as the // per application limit is not exceeded and total across all // applications does not exceed the global limit. Acquire(ctx context.Context, appName string) error // Release releases the lock for the given application. Release(appName string) }
ResourceDownloadLock is used to limit the number of concurrent resource downloads and per application. The total number of downloads across all applications cannot exceed the global limit.
type ResourceGetter ¶
type ResourceGetter interface { // GetResource returns a reader for the resource's data. That data // is streamed from the charm store. The charm's revision, if any, // is ignored. GetResource(charmhub.ResourceRequest) (charmhub.ResourceData, error) }
ResourceGetter provides the functionality for getting a resource file.
type ResourceOpener ¶
type ResourceOpener struct {
// contains filtered or unexported fields
}
ResourceOpener is a ResourceOpener for charmhub. It will first look on the controller for the requested resource.
func (ResourceOpener) OpenResource ¶
func (ro ResourceOpener) OpenResource(ctx context.Context, name string) (opener coreresource.Opened, err error)
OpenResource implements server.ResourceOpener.
func (ResourceOpener) SetResourceUsed ¶
func (ro ResourceOpener) SetResourceUsed(ctx context.Context, resName string) error
SetResourceUsed records that the resource is currently in use.
type ResourceOpenerArgs ¶
type ResourceOpenerArgs struct { State *state.State ResourceService ResourceService ModelConfigService ModelConfigService ApplicationService ApplicationService CharmhubClientGetter ResourceClientGetter }
ResourceOpenerArgs are common arguments for the 2 types of ResourceOpeners: for unit and for application.
type ResourceService ¶
type ResourceService interface { // GetApplicationResourceID returns the UUID of the resource specified by natural key // of application and resource name. GetApplicationResourceID(ctx context.Context, args resource.GetApplicationResourceIDArgs) (coreresource.UUID, error) // GetResource returns the identified application resource. GetResource(ctx context.Context, resourceUUID coreresource.UUID) (coreresource.Resource, error) // OpenResource returns the details of and a reader for the resource. // // The following error types can be expected to be returned: // - [resourceerrors.StoredResourceNotFound] if the specified resource is not // in the resource store. OpenResource(ctx context.Context, resourceUUID coreresource.UUID) (coreresource.Resource, io.ReadCloser, error) // StoreResource adds the application resource to blob storage and updates the // metadata. It also sets the retrival information for the resource. StoreResource(ctx context.Context, args resource.StoreResourceArgs) error // SetUnitResource sets the unit as using the resource. SetUnitResource( ctx context.Context, resourceUUID coreresource.UUID, unitUUID coreunit.UUID, ) error // SetApplicationResource marks an existing resource as in use by a CAAS // application. SetApplicationResource( ctx context.Context, resourceUUID coreresource.UUID, ) error }