GithubHelp home page GithubHelp logo

isabella232 / interface-http Goto Github PK

View Code? Open in Web Editor NEW

This project forked from charmed-kubernetes/interface-http

0.0 0.0 0.0 26 KB

Interface layer for the basic http interface protocol

Python 100.00%

interface-http's Introduction

Overview

This interface layer implements the basic form of the http interface protocol, which is used for things such as reverse-proxies, load-balanced servers, REST service discovery, et cetera.

Usage

Provides

By providing the http interface, your charm is providing an HTTP server that can be load-balanced, reverse-proxied, used as a REST endpoint, etc.

Your charm need only provide the port on which it is serving its content, as soon as the {relation_name}.available state is set:

@when('website.available')
def configure_website(website):
    website.configure(port=hookenv.config('port'))

Requires

By requiring the http interface, your charm is consuming one or more HTTP servers, as a REST endpoint, to load-balance a set of servers, etc.

Your charm should respond to the {relation_name}.available state, which indicates that there is at least one HTTP server connected.

The services() method returns a list of available HTTP services and their associated hosts and ports.

The return value is a list of dicts of the following form:

[
    {
        'service_name': name_of_service,
        'hosts': [
            {
                'hostname': address_of_host,
                'port': port_for_host,
            },
            # ...
        ],
    },
    # ...
]

A trivial example of handling this interface would be:

from charms.reactive.helpers import data_changed

@when('reverseproxy.available')
def update_reverse_proxy_config(reverseproxy):
    services = reverseproxy.services()
    if not data_changed('reverseproxy.services', services):
        return
    for service in services:
        for host in service['hosts']:
            hookenv.log('{} has a unit {}:{}'.format(
                services['service_name'],
                host['hostname'],
                host['port']))

interface-http's People

Contributors

adamisrael avatar bcsaller avatar cynerva avatar hyperbolic2346 avatar johnsca avatar ktsakalozos avatar kwmonroe avatar merlijn-sebrechts avatar wolsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.