Skip to content

Apodini/ApodiniSustainability

Repository files navigation

Apodini Sustainability

Build codecov

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.

Hello World

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()
    }
}

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

License

This project is licensed under the MIT License. See Licenses for more information.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages