Changes: - Remove deprecated Fengling.Activity and YarpGateway.Admin projects - Add points processing services with distributed lock support - Update Vben frontend with gateway management pages - Add gateway config controller and database listener - Update routing to use header-mixed-nav layout - Add comprehensive test suites for Member services - Add YarpGateway integration tests - Update package versions in Directory.Packages.props Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
119 lines
4.3 KiB
PowerShell
119 lines
4.3 KiB
PowerShell
# Service Gateway Registration Script
|
||
param(
|
||
[string]$Prefix = "activity",
|
||
[string]$Version = "v1",
|
||
[string]$GatewayUrl = "http://localhost:5000",
|
||
[string]$Address = "http://localhost:5001",
|
||
[string]$DestinationId = $null,
|
||
[int]$Weight = 1,
|
||
[switch]$Global = $true,
|
||
[string]$TenantCode = ""
|
||
)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
# Derived values
|
||
$ClusterId = "$Prefix-service"
|
||
if ([string]::IsNullOrEmpty($DestinationId)) {
|
||
$DestinationId = "$Prefix-1"
|
||
}
|
||
$PathPattern = "/$Prefix/$Version/{**path}"
|
||
|
||
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
||
Write-Host "║ Service Gateway Registration ║" -ForegroundColor Cyan
|
||
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# Step 1: Add Service Instance
|
||
Write-Host "[1/3] Adding service instance..." -ForegroundColor Yellow
|
||
|
||
$instanceBody = @{
|
||
destinationId = $DestinationId
|
||
address = $Address
|
||
weight = $Weight
|
||
} | ConvertTo-Json
|
||
|
||
try {
|
||
$null = Invoke-RestMethod -Uri "$GatewayUrl/api/gateway/clusters/$ClusterId/instances" `
|
||
-Method Post `
|
||
-ContentType "application/json" `
|
||
-Body $instanceBody
|
||
Write-Host " ✓ Instance: $DestinationId -> $Address" -ForegroundColor Green
|
||
}
|
||
catch {
|
||
if ($_.Exception.Response.StatusCode -eq "BadRequest") {
|
||
Write-Host " ℹ Instance may already exist" -ForegroundColor Gray
|
||
}
|
||
else {
|
||
throw $_
|
||
}
|
||
}
|
||
|
||
# Step 2: Add Route
|
||
Write-Host ""
|
||
Write-Host "[2/3] Configuring gateway route..." -ForegroundColor Yellow
|
||
|
||
if ($Global) {
|
||
$routeBody = @{
|
||
serviceName = $Prefix
|
||
clusterId = $ClusterId
|
||
pathPattern = $PathPattern
|
||
} | ConvertTo-Json
|
||
$routeType = "Global"
|
||
}
|
||
else {
|
||
$routeBody = @{
|
||
serviceName = $Prefix
|
||
pathPattern = $PathPattern
|
||
} | ConvertTo-Json
|
||
$routeType = "Tenant [$TenantCode]"
|
||
}
|
||
|
||
try {
|
||
$routeUrl = if ($Global) {
|
||
"$GatewayUrl/api/gateway/routes/global"
|
||
}
|
||
else {
|
||
"$GatewayUrl/api/gateway/tenants/$TenantCode/routes"
|
||
}
|
||
$null = Invoke-RestMethod -Uri $routeUrl `
|
||
-Method Post `
|
||
-ContentType "application/json" `
|
||
-Body $routeBody
|
||
Write-Host " ✓ Route: $PathPattern -> $ClusterId" -ForegroundColor Green
|
||
}
|
||
catch {
|
||
if ($_.Exception.Response.StatusCode -eq "BadRequest") {
|
||
Write-Host " ℹ Route may already exist" -ForegroundColor Gray
|
||
}
|
||
else {
|
||
throw $_
|
||
}
|
||
}
|
||
|
||
# Step 3: Reload Config
|
||
Write-Host ""
|
||
Write-Host "[3/3] Reloading gateway configuration..." -ForegroundColor Yellow
|
||
$null = Invoke-RestMethod -Uri "$GatewayUrl/api/gateway/reload" -Method Post
|
||
Write-Host " ✓ Configuration reloaded" -ForegroundColor Green
|
||
|
||
# Summary
|
||
Write-Host ""
|
||
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
|
||
Write-Host " Service Registered Successfully!" -ForegroundColor Cyan
|
||
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
Write-Host " Service: $Prefix" -ForegroundColor White
|
||
Write-Host " Version: $Version" -ForegroundColor White
|
||
Write-Host " Cluster: $ClusterId" -ForegroundColor White
|
||
Write-Host " Type: $routeType" -ForegroundColor White
|
||
Write-Host " Pattern: $PathPattern" -ForegroundColor White
|
||
Write-Host " Address: $Address" -ForegroundColor White
|
||
Write-Host ""
|
||
Write-Host " Available Endpoints:" -ForegroundColor Yellow
|
||
Write-Host " GET $GatewayUrl/$Prefix/$Version/campaigns" -ForegroundColor Cyan
|
||
Write-Host " POST $GatewayUrl/$Prefix/$Version/campaigns" -ForegroundColor Cyan
|
||
Write-Host " GET $GatewayUrl/$Prefix/$Version/campaigns/{id}" -ForegroundColor Cyan
|
||
Write-Host " POST $GatewayUrl/$Prefix/$Version/campaigns/{id}/publish" -ForegroundColor Cyan
|
||
Write-Host ""
|