Skip to content

refactor: Phase 1 — role-based OSS strategy, built into unified Bootstrap (#352)#353

Merged
JusterZhu merged 1 commit into
masterfrom
feat/role-based-strategies
May 24, 2026
Merged

refactor: Phase 1 — role-based OSS strategy, built into unified Bootstrap (#352)#353
JusterZhu merged 1 commit into
masterfrom
feat/role-based-strategies

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

Phase 1 of the v2 role-based strategy refactoring. Built-in OSS mode through the unified Bootstrap.

Changes

Added

  • AppType.OSSApp = 3 — OSS update mode identifier
  • OSSUpdateStrategy : IStrategy — absorbs old OSSStrategy, implements standard strategy interface

Updated

  • GeneralUpdateBootstrap.LaunchAsync() — new AppType.OSSApp dispatch:
    • Client-side: downloads version JSON from OSS, compares versions, starts upgrade process
    • Upgrade-side: reads GlobalConfigInfoOSS from environment, executes OSSUpdateStrategy
  • Built-in OSS helpers: DownloadOssFile(), IsOssUpgrade()

Removed (obsolete → absorbed)

  • OSSStrategy.cs — replaced by OSSUpdateStrategy
  • GeneralUpdateOSS.cs — functionality moved to LaunchOssAsync()
  • GeneralClientOSS.cs — functionality moved to LaunchOssAsync()

OSS usage after this PR

// All-in-one OSS client
new GeneralUpdateBootstrap()
    .Option(UpdateOptions.AppType, AppType.OSSApp)
    .Option(UpdateOptions.UpdateUrl, "https://oss-bucket.aliyuncs.com/versions.json")
    .SetConfig(cfg)
    .LaunchAsync();

Verification

  • Full solution: 0 errors, 0 warnings
  • Tests: 54/55 passed (1 pre-existing ConfiginfoBuilderTests failure)

Up next (Phase 1b)

Extract ClientUpdateStrategy and UpgradeUpdateStrategy from Bootstrap's inline methods.

Closes #352

- Added AppType.OSSApp = 3 for OSS update mode
- Created OSSUpdateStrategy (implements IStrategy), absorbs old OSSStrategy logic
- Bootstrap now dispatches to OSS on AppType.OSSApp:
  client-side: download version config, compare, start upgrade process
  upgrade-side: read GlobalConfigInfoOSS from env, execute OSSUpdateStrategy
- Removed legacy files: OSSStrategy.cs, GeneralUpdateOSS.cs, GeneralClientOSS.cs
- OSS mode is now fully built-in — no separate entry classes needed

Closes #352
Copilot AI review requested due to automatic review settings May 24, 2026 08:29
@JusterZhu JusterZhu added the refactor Refactor some existing code. label May 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Phase 1 of the “role-based strategy” refactor aiming to consolidate OSS update support into the unified GeneralUpdateBootstrap, replacing the legacy OSS bootstrap/strategy types.

Changes:

  • Added AppType.OSSApp = 3 as an OSS update mode identifier.
  • Introduced OSSUpdateStrategy : IStrategy to replace the legacy OSSStrategy / OSS bootstraps.
  • Removed obsolete OSS entrypoints (GeneralUpdateOSS, GeneralClientOSS) and legacy OSSStrategy.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs Adds a new OSS strategy implementation for downloading/decompressing OSS packages and starting the app.
src/c#/GeneralUpdate.Core/Strategy/OSSStrategy.cs Removes the legacy OSS strategy class.
src/c#/GeneralUpdate.Core/Configuration/AppType.cs Adds OSSApp constant for OSS mode.
src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateOSS.cs Removes obsolete OSS upgrade bootstrap entrypoint.
src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs Minimal diff shown (BOM), but file is expected by PR description to host OSS dispatch.
src/c#/GeneralUpdate.Core/Bootstrap/GeneralClientOSS.cs Removes obsolete OSS client bootstrap entrypoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +34
private GlobalConfigInfo? _configInfo;
private readonly string _appPath = AppDomain.CurrentDomain.BaseDirectory;
private const int TimeOut = 60;

public void Create(GlobalConfigInfo parameter)
{
_configInfo = parameter ?? throw new ArgumentNullException(nameof(parameter));
}
Comment on lines +43 to +49
var versionFileName = $"{_configInfo.MainAppName ?? _configInfo.AppName}_versions.json";

GeneralTracer.Debug("OSSUpdateStrategy: 1. Reading version configuration file.");
var jsonPath = Path.Combine(_appPath, versionFileName);
if (!File.Exists(jsonPath))
throw new FileNotFoundException(jsonPath);

Comment on lines +79 to +90
public void StartApp()
{
var appName = _configInfo?.MainAppName ?? _configInfo?.AppName;
if (string.IsNullOrEmpty(appName)) return;

var appPath = Path.Combine(_appPath, appName);
if (!File.Exists(appPath))
throw new FileNotFoundException($"Application not found: {appPath}");

Process.Start(appPath);
GeneralTracer.Debug("OSSUpdateStrategy: application started.");
}
Comment on lines +1 to 4
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@JusterZhu JusterZhu merged commit d0471ee into master May 24, 2026
1 check passed
@JusterZhu JusterZhu deleted the feat/role-based-strategies branch May 24, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactor some existing code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 1: Role-based strategy architecture — Client/Upgrade/OSS strategies + unified Bootstrap

2 participants