tankerkoenig-fuel-machinery

module
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2022 License: MIT

README

tankerkoenig-fuel-machinery - Fetch gas stations from tankerkoenig api and persist them into an Orion Context Broker

Go Report Card Contributor Covenant Dockerhub Badge

Main branch Main branch docker

Scope

This project aims to fetch gas stations with fuel prices from https://creativecommons.tankerkoenig.de api and persist the result into an orion context broker entity.

You should provide the api token and the api search parameters with env variables.

Visit https://creativecommons.tankerkoenig.de in order to obtain an api key.

Usage

Docker image

phoops/tankerkoenig-fuel-machinery

Env Variables
Name Description Required Type
ENVIRONMENT The environment of the application True String
API_BASE_URL TankerKoenig api base url True String
API_TOKEN TankerKoenig authentication token True String
API_SEARCH_RADIUS TankerKoenig api search radius True Float
ORION_BASE_URL Context Broker base url True String
CITY_NAME The name of the city, will be checked against api place field True String
CITY_LAT Latitude of the city True Float
CITY_LON Longitude of the city True Float
ORION_SERVICE Context broker service False String
ORION_SERVICE_PATH Context broker service path False String
EXTRACT_OPENING_TIMES Enable opening hours extractions for gas stations False Boolean

Orion Data Model

The data model persisted on orion has that shape


    {
        "id": "FuelStation:d057546e-9c10-4a27-8b56-afaab22ee845",
        "type": "FuelStation",
        "TimeInstant": {
            "type": "DateTime",
            "value": "2022-02-10T13:11:26.671Z",
            "metadata": {}
        },
        "address": {
            "type": "Text",
            "value": "Delimbiyra Miraharice Straße, 29",
            "metadata": {}
        },
        "availableFuels": {
            "type": "StructuredValue",
            "value": [
                {
                        "type": "DIESEL",
                        "price": 1.6
                }
                {
                        "type": "E10",
                        "price": 1.83
                }
            ],
            "metadata": {}
        },
        "brand": {
            "type": "Text",
            "value": "Ghilanna Greneiros",
            "metadata": {}
        },
        "city": {
            "type": "Text",
            "value": "Wolfsburg",
            "metadata": {}
        },
        "isOpen": {
            "type": "Boolean",
            "value": false,
            "metadata": {}
        },
        "location": {
            "type": "geo:point",
            "value": "52.417333,10.805207,",
            "metadata": {}
        },
        "name": {
            "type": "Text",
            "value": "Shanyrria Umedan",
            "metadata": {}
        },
        "postcode": {
            "type": "Text",
            "value": "38446",
            "metadata": {}
        },
    }

Development

Prerequisites
Available tasks
    * build-and-push-docker-images:                 Build all images, then push to dockerhub
    * build-docker-images:                          Build all images
    * build-docker-tankerkoenig-fuel-machinery:     Build tankerkoenig-fuel-machinery prod container
    * build-tankerkoenig-fuel-machinery-dev:        Build tankerkoenig-fuel-machinery executable with support for debugging
    * build-tankerkoenig-fuel-machinery-prod:       Build tankerkoenig-fuel-machinery binary for production release
    * install-repo-hooks:                           Copy and enable the project hooks (linting, etc...)
    * lint:                                         lint the project
    * push-docker-images:                           Push all images to dockerhub
    * push-docker-tankerkoenig-fuel-machinery:      Push tankerkoenig-fuel-machinery prod container to dockerhub
    * run-tankerkoenig-fuel-machinery-dev:          Run tankerkoenig-fuel-machinery with air
Testing

Start docker-compose first.

go test -v ./...

The pipeline will run tests at each push and prior to the docker image building.

Interface mock generation

mockery --name <interface-name> --output ./internal/<package>/mocks --recursive

Attributions

www.tankerkoenig.de

The data is subject to the Creative Commons license "CC BY 4.0", see https://creativecommons.org/licenses/by/4.0/deed.de, attribution is required in particular (e.g. a link to www.tankerkoenig.de ) For apps, this attribution must also be included in the info text in the store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL