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 }