jonasbn / pxy-redirect-ow-function

Experimental open whisk function for deployment on DigitalOceans function platform

Home Page:https://pxy.fi/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pxy-redirect-ow-function

Introduction

This is an experimental serverless implementation of the pxy-redirect service I have created for deployment on DigitalOcean.

It's goal is to take a short URL following a required format and redirect to the designated URL.

The scheme is:

<domain>/<version>/<fragment>

Redirects to:

https://<domain>/<version>/tools/clang/docs/DiagnosticsReference.html#<fragment>

Example:

https://pxy.fi/5/rsanitize-address

Redirects to:

https://releases.llvm.org/5.0.0/tools/clang/docs/DiagnosticsReference.html#rsanitize-address

Do note the version number is expanded from a single digit to a 3 part version number.

This scheme is used by clang diagnostic flags matrix generator. Please see my blog post for the long version.

pxy-redirect-ow-function is transparent, so introduction of a version 16.0.0 would work out of the box. The pages utilizing the service and the generator however rely on human interaction in order to be updated.

Diagnostics

This is a collection of errors which can be emitted from the service. Not all are visible to the end user and not all error scenarios are documented.

This section and documentation is primarily aimed and what can be recovered from.

Unable to assemble URL (400)

This is the most common error it will provide additional information as to why the request was regarded as a bad request.

insufficient parts in provided url

The the request does not contain enough parts to assemble the redirect target URL.

The URL should consist of 2 parts.

  1. Version number
  2. Fragment
https://pxy.fi/<version number>/<fragment>

Do note the version number is expanded from a single digit to a 3 part version number.

Luckily command line options (fragments) are only introduced or removed in major versions (X.0.0).

first part of url is not a number

The first part of the URL should be a number (integer), which is translated to a version number.

https://pxy.fi/<version number>/<fragment>

Do note the version number is expanded from a single digit to a 3 part version number.

Not all numbers are supported since documentation for all versions is not available.

To my knowledge version ranging from 4.0.0 to 15.0.0 are supported, for reference these would be 4 and 15.

second part of url is not a string

The second part of the URL should be a string.

https://pxy.fi/<version number>/<fragment>

The second part is the fragment.

Please visit the releases.llvm.org website for more details.

An example of a good fragment, which is available in all versions is: wall

https://pxy.fi/4/wall

Redirects to:

https://releases.llvm.org/4.0.0/tools/clang/docs/DiagnosticsReference.html#wall

The version number can be exchanged for a number between 4 and 15.

Logging

The default log level is INFO

It can be set to DEBUG via an environment variable, see below.

See the article on log levels for more information.

The logging is currently collected on logtail, from Better Stack.

Monitoring

Currently the service is monitored using Better Uptime from Better Stack.

A public status page is available.

It monitors the following:

  • The reverse proxy (Nginx) via a health check
  • Calling a redirectable URL and checking the response code. The URL goes via the reverse proxy (Nginx) and the service (OpenWhisk)
  • The service (OpenWhisk) via a heartbeat

Environment Variables

If the environment variable LOG_LEVEL is specified as debug the log level will be set to DEBUG.

Resources and References

About

Experimental open whisk function for deployment on DigitalOceans function platform

https://pxy.fi/

License:MIT License


Languages

Language:Go 100.0%