package live import ( "cloud.o-forge.io/core/oc-lib/models/common/enum" "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" ) type ServiceProtocol int const ( HTTP ServiceProtocol = iota GRPC WEBSOCKET TCP ) func (p ServiceProtocol) String() string { return [...]string{"HTTP", "GRPC", "WEBSOCKET", "TCP"}[p] } // 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 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"` Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"` // Infrastructure is the infrastructure } func (d *LiveService) GetAccessor(request *tools.APIRequest) utils.Accessor { return NewAccessor[*LiveService](tools.LIVE_SERVICE, request) } func (r *LiveService) IsCompatible(service map[string]interface{}) bool { return service["infrastructure"] == r.Infrastructure }