mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-10 02:25:56 +00:00
Restore commercial monitored-system admission hook contract
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package extensions
|
||||
|
||||
// MonitoredSystemAdmissionInput describes the counted-system state that a
|
||||
// commercial runtime can use to decide whether adding a candidate should be
|
||||
// admitted.
|
||||
type MonitoredSystemAdmissionInput struct {
|
||||
Current int
|
||||
Additional int
|
||||
Limit int
|
||||
UsageAvailable bool
|
||||
UsageUnavailableReason string
|
||||
CandidateCountsTowardCap bool
|
||||
}
|
||||
|
||||
// MonitoredSystemAdmissionDecision is the runtime admission decision returned
|
||||
// by commercial policy hooks.
|
||||
type MonitoredSystemAdmissionDecision struct {
|
||||
Current int
|
||||
Additional int
|
||||
Limit int
|
||||
UsageAvailable bool
|
||||
UsageUnavailableReason string
|
||||
Exceeded bool
|
||||
}
|
||||
@@ -97,6 +97,11 @@ type BusinessHooks struct {
|
||||
// CreateAlertAnalyzer creates the premium alert-triggered analyzer.
|
||||
// Returns nil in OSS. Enterprise provides a concrete implementation.
|
||||
CreateAlertAnalyzer func(deps aicontracts.AlertAnalyzerDeps) aicontracts.AlertAnalyzer
|
||||
|
||||
// ResolveMonitoredSystemAdmissionPolicy lets commercial runtimes own
|
||||
// monitored-system admission policy while the public server owns inventory
|
||||
// projection and the shared API contract.
|
||||
ResolveMonitoredSystemAdmissionPolicy func(context.Context, extensions.MonitoredSystemAdmissionInput) extensions.MonitoredSystemAdmissionDecision
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -122,7 +127,8 @@ func runtimeIdentityForBusinessHooks(h BusinessHooks) pkglicensing.RuntimeIdenti
|
||||
h.CreateRemediationEngine != nil ||
|
||||
h.CreateInvestigationStore != nil ||
|
||||
h.CreateInvestigationOrchestrator != nil ||
|
||||
h.CreateAlertAnalyzer != nil {
|
||||
h.CreateAlertAnalyzer != nil ||
|
||||
h.ResolveMonitoredSystemAdmissionPolicy != nil {
|
||||
return pkglicensing.ProRuntimeIdentity()
|
||||
}
|
||||
return pkglicensing.CommunityRuntimeIdentity()
|
||||
|
||||
@@ -55,6 +55,15 @@ func TestRuntimeIdentityForBusinessHooks(t *testing.T) {
|
||||
if got.Build != pkglicensing.RuntimeBuildPro {
|
||||
t.Fatalf("enterprise hooks runtime build=%q, want pro", got.Build)
|
||||
}
|
||||
|
||||
got = runtimeIdentityForBusinessHooks(BusinessHooks{
|
||||
ResolveMonitoredSystemAdmissionPolicy: func(context.Context, extensions.MonitoredSystemAdmissionInput) extensions.MonitoredSystemAdmissionDecision {
|
||||
return extensions.MonitoredSystemAdmissionDecision{}
|
||||
},
|
||||
})
|
||||
if got.Build != pkglicensing.RuntimeBuildPro {
|
||||
t.Fatalf("commercial admission hook runtime build=%q, want pro", got.Build)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPerformAutoImport_Success(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user