Documentation
¶
Index ¶
- Variables
- type CdnInstance
- type CdnResource
- func (r *CdnResource) CopyV86ImageToSpace(ctx context.Context, req *s4wave_cdn.CopyV86ImageToSpaceRequest) (*s4wave_cdn.CopyV86ImageToSpaceResponse, error)
- func (r *CdnResource) GetCdnSpaceId(_ context.Context, _ *s4wave_cdn.GetCdnSpaceIdRequest) (*s4wave_cdn.GetCdnSpaceIdResponse, error)
- func (r *CdnResource) GetMux() srpc.Invoker
- func (r *CdnResource) MountCdnSpace(ctx context.Context, _ *s4wave_cdn.MountCdnSpaceRequest) (*s4wave_cdn.MountCdnSpaceResponse, error)
- type Registry
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownCdn = errors.New("unknown cdn id")
ErrUnknownCdn is returned when Lookup is called with an unregistered cdn_id. Today only the default slot is populated.
Functions ¶
This section is empty.
Types ¶
type CdnInstance ¶
type CdnInstance struct {
// contains filtered or unexported fields
}
CdnInstance owns the process-scoped singleton CdnSharedObject and the shared CdnBlockStore backing it for a single CDN (identified by cdn_id in the enclosing registry). Future multi-CDN support will create one CdnInstance per configured CDN; today only the default instance exists.
CdnInstance is process-lived: started once by the Registry on first lookup, torn down via Close when the Registry is stopped.
func (*CdnInstance) Close ¶
func (c *CdnInstance) Close()
Close stops the refresh routine and releases the block-store cache.
func (*CdnInstance) GetBlockStore ¶
func (c *CdnInstance) GetBlockStore() *cdn_bstore.CdnBlockStore
GetBlockStore returns the CDN block store.
func (*CdnInstance) GetSharedObject ¶
func (c *CdnInstance) GetSharedObject() *cdn_sharedobject.CdnSharedObject
GetSharedObject returns the underlying CDN SharedObject.
func (*CdnInstance) GetSpaceID ¶
func (c *CdnInstance) GetSpaceID() string
GetSpaceID returns the CDN Space ULID.
func (*CdnInstance) Refresh ¶
func (c *CdnInstance) Refresh()
Refresh triggers a cheap invalidate + snapshot refresh. Called by upstream notification plumbing (cdn-root-changed WS frame, wired in iter 4) so mounted clients see a new snapshot shortly after the CDN root moves.
type CdnResource ¶
type CdnResource struct {
// contains filtered or unexported fields
}
CdnResource is a per-mount handle implementing CdnResourceService for a single CdnInstance. The resource does not own the instance; it is a thin adapter so the root GetCdn RPC (added in a later iteration) can hand out a resource reference without exposing the Registry directly.
func NewCdnResource ¶
func NewCdnResource(le *logrus.Entry, b bus.Bus, instance *CdnInstance) *CdnResource
NewCdnResource constructs a CdnResource bound to the supplied instance. The caller retains ownership of the instance; CdnResource does not tear it down on its own.
func (*CdnResource) CopyV86ImageToSpace ¶ added in v0.51.0
func (r *CdnResource) CopyV86ImageToSpace( ctx context.Context, req *s4wave_cdn.CopyV86ImageToSpaceRequest, ) (*s4wave_cdn.CopyV86ImageToSpaceResponse, error)
CopyV86ImageToSpace copies a V86Image from this CDN Space into a user-owned destination Space identified by session index + destination space id. Source is a fresh read-only WorldEngine built from the bound CdnInstance; destination is resolved via space_resolve.ResolveSpace using the caller's session. Both engines are released before the RPC returns. Underlying copy semantics (metadata block + five asset edges, dedupe by target key) are handled by core/cdn.CopyV86ImageFromCdn.
func (*CdnResource) GetCdnSpaceId ¶
func (r *CdnResource) GetCdnSpaceId( _ context.Context, _ *s4wave_cdn.GetCdnSpaceIdRequest, ) (*s4wave_cdn.GetCdnSpaceIdResponse, error)
GetCdnSpaceId returns the CDN Space ULID this resource is bound to.
func (*CdnResource) GetMux ¶
func (r *CdnResource) GetMux() srpc.Invoker
GetMux returns the rpc mux.
func (*CdnResource) MountCdnSpace ¶
func (r *CdnResource) MountCdnSpace( ctx context.Context, _ *s4wave_cdn.MountCdnSpaceRequest, ) (*s4wave_cdn.MountCdnSpaceResponse, error)
MountCdnSpace mounts the CDN SharedObject as a read-only Space resource on the caller's client. Reuses the shared cdn_sharedobject.NewWorldEngine + NewCdnSpaceBody + resource_space.NewSpaceResource machinery that backs the CdnBodyType branch in resource_sobject.MountSharedObjectBody, so both mount paths produce structurally identical SpaceResources.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns the process-scoped map of CdnInstances keyed by cdn_id. The default instance (empty id) is lazily constructed on first lookup against the production or SPACEWAVE_CDN_SPACE_ID-overridden Space id. Future configs can register additional instances via a constructor extension once the first non-default CDN is introduced.
func NewRegistry ¶
NewRegistry constructs a Registry. The returned registry owns a detached lifecycle context used to scope any instance-level background routines (e.g. refresh routines). Close cancels that context and tears down all registered instances. The CDN singleton is anonymous: no peer id is required because the CDN Space is not part of any session's provider account.
func (*Registry) Close ¶
func (r *Registry) Close()
Close tears down every registered instance and cancels the registry lifecycle context. Safe to call more than once.
func (*Registry) Lookup ¶
func (r *Registry) Lookup(cdnID string) (*CdnInstance, error)
Lookup returns the CdnInstance registered under cdnID, constructing the default slot on first call. Unknown non-default ids return ErrUnknownCdn.
func (*Registry) NotifyRootChanged ¶
NotifyRootChanged wakes up the CdnInstance whose SpaceID matches spaceID so the downstream block store cache is invalidated and the cached snapshot is refreshed. Called when an upstream cdn-root-changed signal arrives (e.g. the session-level WS frame). Unknown spaceIDs are silently ignored so future CDNs that this process has not registered yet do not produce spurious errors. Returns true when a matching instance was found.