Skip to content

Instantly share code, notes, and snippets.

View KamilLelonek's full-sized avatar
🏋️‍♂️
Do you even lift?

Kamil Lelonek KamilLelonek

🏋️‍♂️
Do you even lift?
View GitHub Profile
config :healthchex,
liveness_path: "/health/live",
liveness_response: "OK"
defmodule PlainPlug do
use Plug.Router
plug(Liveness)
# regular paths defined here
end
defmodule PlugForward do
use Plug.Router
plug(:match)
plug(:dispatch)
forward(
"/health/live",
to: Liveness
)
defmodule List do
def flatten(list, acc \\ [])
def flatten([], acc), do: acc
def flatten([[] | t], acc), do: flatten(t, acc)
def flatten([h | t], acc) when is_list(h), do: flatten(h, flatten(t, acc))
def flatten([h | t], acc), do: [h | flatten(t, acc)]
end
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: kamil.lelonek.me
http:
apiVersion: v1
kind: Service
metadata:
name: example-node-port
spec:
type: NodePort
selector:
app: api
ports:
- port: 4444
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 1
selector:
matchLabels:
app: api
template:
resource "google_project_service" "kubernetes" {
project = "k8s-project"
service = "container.googleapis.com"
}
resource "google_container_cluster" "kubernetes" {
name = "k8s-cluster"
depends_on = ["google_project_service.kubernetes"]
initial_node_count = 1
const address = "localhost:50051"
func main() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := pb.NewGravatarServiceClient(conn)
const port = ":50051"
type gravatarService struct{}
func (s *gravatarService) Generate(ctx context.Context, in *pb.GravatarRequest) (*pb.GravatarResponse, error) {
log.Printf("Received email %v with size %v", in.Email, in.Size)
return &pb.GravatarResponse{Url: gravatar(in.Email, in.Size)}, nil
}
func main() {