Two seams the hosts needed, both backward compatible.
Storage: artifacts are served through WarpEngine::Storage.adapter instead of
raw filesystem calls. The default :local adapter keeps the previous behaviour
byte for byte, including the path traversal guard. A host can now set
config.storage_adapter to any object answering file?/directory?/locate and
serve builds from an object store - FileService and /api/download both honour
a Location.redirect, so a signing adapter turns them into redirects.
DownloadService#create still returns an absolute path (nil when missing) for
existing callers; #locate is the new entry point that can also return a
redirect. Ingestion (upload, extraction, file manager) stays local for now.
Publish: PublishService emits ActiveSupport::Notifications
("warp_engine.publish") with platform/name/version/software/release, so hosts
can react to a new build without hanging callbacks on the models.
WarpEngine.instruments_publish? lets a host feature-detect and keep its
fallback for older engine versions.
32 lines
1.1 KiB
Ruby
32 lines
1.1 KiB
Ruby
module WarpEngine
|
|
class PublishService
|
|
# Az esemény neve, amit a host lehallgathat. A payload:
|
|
# platform: String, name: String, version: String,
|
|
# software: WarpEngine::Software, release: WarpEngine::Release
|
|
NOTIFICATION = "warp_engine.publish".freeze
|
|
|
|
def publish(input)
|
|
unless WarpEngine::PlatformLink::SUPPORTED_PLATFORMS.include?(input.platform)
|
|
raise ArgumentError, "Unsupported platform: #{input.platform}"
|
|
end
|
|
|
|
release = "WarpEngine::Platforms::#{input.platform.camelize}::Service".constantize
|
|
.new.update(input.name, input.version)
|
|
|
|
# A publikálás az egyetlen pont, ahol új build kerül a katalógusba —
|
|
# a host innen tud rá reagálni (értesítés, feed, csatorna-előléptetés)
|
|
# anélkül, hogy modell-callbackre kellene kapaszkodnia.
|
|
ActiveSupport::Notifications.instrument(
|
|
NOTIFICATION,
|
|
platform: input.platform,
|
|
name: input.name,
|
|
version: input.version,
|
|
software: release.respond_to?(:software) ? release.software : nil,
|
|
release: release
|
|
)
|
|
|
|
release
|
|
end
|
|
end
|
|
end
|