This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
connection_pooling.py | |
The idea for our Azure clients is that unlike database connections | |
*all of our clients can be reused* across multiple requesters. | |
What we really need to achieve is the following: | |
- A "pool" of connections, where | |
- Each connection may be shared by more than 1 requester, and | |
- Each connection has an idle lifespan. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.poetry] | |
name = "service-bus-otel-test" | |
version = "1.0.0" | |
description = "Service Bus otel test" | |
authors = ["Erik Aker <eraker@gmail.com>"] | |
[tool.poetry.dependencies] | |
python = "^3.11" | |
azure-core = "^1.26.3" | |
azure-servicebus = "7.8.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""compose.py - Function composition in Python | |
""" | |
# Python module for function composition | |
from functools import reduce, wraps | |
from itertools import chain | |
from typing import Callable, Generic, TypeVar | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do | |
echo "Cloud Init is still configuring the server." | |
sleep 1 | |
done | |
echo "Cloud Init config complete. Lets build some apps!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:stretch-slim as base_os | |
## ensure locale is set during build | |
ENV LANG C.UTF-8 | |
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | |
RUN apt-get update \ | |
&& apt-get install --no-install-recommends -y \ | |
build-essential \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import json | |
import uvicorn | |
from starlette.applications import Starlette | |
from starlette.middleware.base import BaseHTTPMiddleware | |
from starlette.background import BackgroundTask | |
from starlette.responses import JSONResponse, PlainTextResponse, StreamingResponse | |
class TransparentMiddlewareNoStreaming(BaseHTTPMiddleware): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
flask application | |
""" | |
import logging | |
import logging.config | |
import os | |
from flask import Flask | |
import structlog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
module Api.Post | |
( | |
PostApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -o errexit -o verbose | |
if test -f "$HOME/.local/bin/stack" | |
then | |
echo 'Stack is already installed.' | |
else | |
echo "Installing Stack for $TRAVIS_OS_NAME..." | |
URL="https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64" | |
curl --location "$URL" > stack.tar.gz | |
gunzip stack.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Api where | |
import Control.Monad.Reader (ReaderT, runReaderT) | |
import Control.Monad.Trans.Either (EitherT) | |
import Data.Int (Int64) | |
import Servant |
NewerOlder