Addon
This commit is contained in:
@@ -27,6 +27,8 @@ func NewAccessor[T LiveInterface](t tools.DataType, request *tools.APIRequest) *
|
||||
return &LiveDatacenter{}
|
||||
case tools.LIVE_STORAGE:
|
||||
return &LiveStorage{}
|
||||
case tools.LIVE_SERVICE:
|
||||
return &LiveService{}
|
||||
}
|
||||
return &LiveDatacenter{}
|
||||
},
|
||||
|
||||
42
models/live/live_service.go
Normal file
42
models/live/live_service.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
// LiveService is the authoritative description of a hosted service run by the peer.
|
||||
// MaxConcurrent is the only capacity dimension that matters for scheduling:
|
||||
// it caps the number of simultaneous callers the service can accept.
|
||||
// All other service metadata (endpoint, protocol) is live-verified here
|
||||
// rather than trusted from the ServiceResource, which may be stale.
|
||||
type LiveService struct {
|
||||
AbstractLive
|
||||
MaxConcurrent int `json:"max_concurrent" bson:"max_concurrent"`
|
||||
Protocol resources.ServiceProtocol `json:"protocol" bson:"protocol" default:"0"`
|
||||
EndpointPattern string `json:"endpoint_pattern,omitempty" bson:"endpoint_pattern,omitempty"`
|
||||
HealthCheckPath string `json:"health_check_path,omitempty" bson:"health_check_path,omitempty"`
|
||||
}
|
||||
|
||||
func (d *LiveService) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
return NewAccessor[*LiveService](tools.LIVE_SERVICE, request)
|
||||
}
|
||||
|
||||
func (d *LiveService) GetResourceAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
return resources.NewAccessor[*resources.ServiceResource](tools.SERVICE_RESOURCE, request)
|
||||
}
|
||||
|
||||
func (d *LiveService) GetResource() resources.ResourceInterface {
|
||||
return &resources.ServiceResource{}
|
||||
}
|
||||
|
||||
func (d *LiveService) GetResourceInstance() resources.ResourceInstanceITF {
|
||||
return &resources.ServiceInstance{}
|
||||
}
|
||||
|
||||
func (d *LiveService) SetResourceInstance(res resources.ResourceInterface, i resources.ResourceInstanceITF) resources.ResourceInterface {
|
||||
r := res.(*resources.ServiceResource)
|
||||
r.AddInstances(i)
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user