feat: 清理openspec
This commit is contained in:
@@ -30,7 +30,7 @@ func (svc *CoreService) RegisterRunHello(hello domain.RunControlHello) (domain.R
|
||||
return domain.RunControlHelloResult{}, err
|
||||
}
|
||||
if hasComponentAuthIdentity(hello) {
|
||||
if err := svc.validateDedicatedRunHello(hello); err != nil {
|
||||
if err := svc.validateAuthenticatedRunHello(hello); err != nil {
|
||||
return domain.RunControlHelloResult{}, err
|
||||
}
|
||||
auth, err := svc.AuthenticateComponent(domain.ComponentAuthenticationRequest{
|
||||
@@ -76,6 +76,19 @@ func (svc *CoreService) RegisterRunHello(hello domain.RunControlHello) (domain.R
|
||||
if err := svc.upsertRunEndpoint(endpoint); err != nil {
|
||||
return domain.RunControlHelloResult{}, err
|
||||
}
|
||||
if hello.ServerInstanceID != "" && hello.ComponentKind == domain.DistributionComponentRun {
|
||||
instance, instanceErr := svc.store.ServerInstances().Get(hello.ServerInstanceID)
|
||||
if instanceErr != nil {
|
||||
return domain.RunControlHelloResult{}, instanceErr
|
||||
}
|
||||
if instance.RunEndpointID != hello.RunEndpointID {
|
||||
instance.RunEndpointID = hello.RunEndpointID
|
||||
instance.UpdatedAt = stamp
|
||||
if err := svc.store.ServerInstances().Update(instance); err != nil {
|
||||
return domain.RunControlHelloResult{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
previous, previousErr := svc.store.RunControlSessions().Get(hello.RunEndpointID)
|
||||
generation := 1
|
||||
if previousErr == nil {
|
||||
@@ -126,19 +139,22 @@ func (svc *CoreService) RegisterRunHello(hello domain.RunControlHello) (domain.R
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (svc *CoreService) validateDedicatedRunHello(hello domain.RunControlHello) error {
|
||||
func (svc *CoreService) validateAuthenticatedRunHello(hello domain.RunControlHello) error {
|
||||
if hello.ComponentKind != domain.DistributionComponentRun {
|
||||
return validationError("component-authenticated run hello must use the run component")
|
||||
}
|
||||
if hello.RunEndpointID == platformDistributionBuilderEndpointID {
|
||||
return validationError("platform distribution builder cannot register as a server Run")
|
||||
}
|
||||
instance, err := svc.store.ServerInstances().Get(hello.ServerInstanceID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(instance.DeploymentTargetID) == "" && instance.RunEndpointID != dedicatedRunEndpointID(instance.ID) {
|
||||
return nil // legacy Run registrations keep their historical endpoint contract.
|
||||
if hello.PluginID != instance.PluginID {
|
||||
return validationError("Run plugin identity does not match the server instance")
|
||||
}
|
||||
if hello.PluginID != instance.PluginID || hello.RunEndpointID != instance.RunEndpointID {
|
||||
return validationError("run endpoint identity does not match the server binding")
|
||||
if instance.State == domain.ServerInstanceStateDeleted {
|
||||
return validationError("deleted server cannot attach an active Run heartbeat")
|
||||
}
|
||||
instances, err := svc.store.ServerInstances().List(domain.ServerInstanceFilter{RunEndpointID: hello.RunEndpointID})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user