ApodiniSustainability includes metadata definitions for annotating Apodini web services with additional information to enable sustainability in cloud-native applications and the interface exporter to share the information.
This HelloWorld
example shows the annotations of the Apodini web service with metadata and includes the Sustainability
interface exporter in the configuration of the web service.
struct Greeter: Handler {
@Parameter var country: String?
func handle() -> String {
"Hello, \(country ?? "World")! 🚀"
}
var metadata: Metadata {
ExecutionModality(.highPerformance)
ResponseTime(value: 1)
InstanceType(.small)
}
}
struct GreeterService: Component {
var content: some Component {
Greeter()
.description("Say 'Hello' to a country.")
}
var metadata: Metadata {
Optional()
ServiceIdentifier("greeter")
}
}
struct HelloWorld: WebService {
@OptionGroup
var options: SustainabilityDocumentExportOptions
var configuration: Configuration {
Sustainability(options)
}
var content: some Component {
GreeterService()
}
}
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
This project is licensed under the MIT License. See Licenses for more information.