Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(examples): bump examples with recent changes #3575

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions examples/analytics/clickhouse/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion examples/analytics/clickhouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
1. Create some sample data: Flags/Segments/etc. Perform a few evaluations in the Console.
1. Navigate to the `Analytics` tab for the flag that you created and evaluated.
16 changes: 6 additions & 10 deletions examples/analytics/clickhouse/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ services:
- flipt_network
environment:
- CLICKHOUSE_DB=flipt_analytics
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1

flipt:
build: .
image: flipt/flipt:latest
depends_on:
- clickhouse
clickhouse:
condition: service_healthy
ports:
- "8080:8080"
networks:
Expand All @@ -29,14 +32,7 @@ services:
- FLIPT_ANALYTICS_STORAGE_CLICKHOUSE_ENABLED=true
- FLIPT_ANALYTICS_STORAGE_CLICKHOUSE_URL=clickhouse://clickhouse:9000/flipt_analytics
- FLIPT_META_TELEMETRY_ENABLED=false
command:
[
"./tmp/wait-for-it.sh",
"clickhouse:9000",
"--",
"./flipt",
"--force-migrate",
]
command: ["/flipt", "--force-migrate"]

networks:
flipt_network:
4 changes: 2 additions & 2 deletions examples/basic/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GO_VERSION=1.20
ARG GO_VERSION=1.23

FROM golang:${GO_VERSION}-alpine

RUN apk update && apk add --no-cache git
RUN apk add --no-cache git

WORKDIR /example
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
1. Open the example UI at [http://localhost:8000](http://localhost:8000)
1. Switch back to the Flipt UI
Expand Down
14 changes: 10 additions & 4 deletions examples/basic/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
init:
image: flipt/flipt:latest
command: ["./flipt", "import", "flipt.yml"]
command: ["/flipt", "import", "--skip-existing", "flipt.yml"]
environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
Expand All @@ -13,9 +13,10 @@ services:

flipt:
image: flipt/flipt:latest
command: ["./flipt"]
command: ["/flipt"]
depends_on:
- init
init:
condition: service_completed_successfully
ports:
- "8080:8080"
- "9000:9000"
Expand All @@ -26,11 +27,16 @@ services:
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "flipt_data:/var/opt/flipt"
healthcheck:
test: wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health || exit 1
interval: 5s
start_period: 5s

example:
build: .
depends_on:
- flipt
flipt:
condition: service_healthy
ports:
- "8000:8000"
networks:
Expand Down
1 change: 1 addition & 0 deletions examples/basic/flipt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ flags:
- key: example
name: Example
description: An example flag
type: BOOLEAN_FLAG_TYPE
16 changes: 7 additions & 9 deletions examples/basic/go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
module flipt-example

go 1.20
go 1.23

require (
go.flipt.io/flipt-grpc v1.1.0
google.golang.org/grpc v1.56.3
go.flipt.io/flipt-grpc v1.11.0
google.golang.org/grpc v1.67.1
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.3 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
36 changes: 14 additions & 22 deletions examples/basic/go.sum
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.3 h1:I8MsauTJQXZ8df8qJvEln0kYNc3bSapuaSsEsnFdEFU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.3/go.mod h1:lZdb/YAJUSj9OqrCHs2ihjtoO3+xK3G53wTYXFWRGDo=
go.flipt.io/flipt-grpc v1.1.0 h1:Hj9xHDGhqKOAYD+t/yTltGwBXM47v77M0XFNAGFBq+o=
go.flipt.io/flipt-grpc v1.1.0/go.mod h1:mPD3/iuyyb6Dfq9FQmlx0L7syzhthY3MfjI/u2bcGrc=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
go.flipt.io/flipt-grpc v1.11.0 h1:EHtZfelq7lk2nqW8Rx+bKLM+4DShx144aAhFCMj/9Ac=
go.flipt.io/flipt-grpc v1.11.0/go.mod h1:fwyou/igTEr+pKD26XFO1s6aQx4MNbvsKUoaALvQPIw=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc=
google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
22 changes: 8 additions & 14 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
package main

import (
"context"
"flag"
"log"
"net/http"
"text/template"

flipt "go.flipt.io/flipt-grpc"
flipt "go.flipt.io/flipt-grpc/evaluation"

"google.golang.org/grpc"
)
Expand Down Expand Up @@ -43,30 +42,25 @@ func main() {

log.Printf("connected to Flipt server at: %s", fliptServer)

client := flipt.NewFliptClient(conn)
client := flipt.NewEvaluationServiceClient(conn)

t := template.Must(template.ParseFiles("./tmpl/basic.html"))

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
flag, err := client.GetFlag(context.Background(), &flipt.GetFlagRequest{
Key: flagKey,
result, err := client.Boolean(r.Context(), &flipt.EvaluationRequest{
FlagKey: flagKey,
EntityId: "hello-service",
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

if flag == nil {
http.Error(w, "flag not found", http.StatusNotFound)
return
}

log.Printf("got flag: %v", flag)
log.Printf("got flag evaluation: %v", result)

data := data{
FlagKey: flag.Key,
FlagName: flag.Name,
FlagEnabled: flag.Enabled,
FlagKey: flagKey,
FlagEnabled: result.Enabled,
}

if err := t.Execute(w, data); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/tmpl/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<section class="section">
<div class="container">
<div class="tags has-addons">
<span class="tag is-medium">{{ .FlagName }}</span>
<span class="tag is-medium">{{ .FlagKey }}</span>
{{if .FlagEnabled }}
<span class="tag is-success is-medium">Enabled</span>
{{else}}
Expand Down
8 changes: 0 additions & 8 deletions examples/database/cockroachdb/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion examples/database/cockroachdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
2 changes: 1 addition & 1 deletion examples/database/cockroachdb/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
retries: 5

flipt:
build: .
image: flipt/flipt:latest
depends_on:
crdb:
condition: service_healthy
Expand Down
8 changes: 0 additions & 8 deletions examples/database/mysql/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion examples/database/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
11 changes: 8 additions & 3 deletions examples/database/mysql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ services:
- MYSQL_USER=mysql
- MYSQL_PASSWORD=password
- MYSQL_ALLOW_EMPTY_PASSWORD=true
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 5s
retries: 5

flipt:
build: .
image: flipt/flipt:latest
depends_on:
- mysql
mysql:
condition: service_healthy
ports:
- "8080:8080"
networks:
Expand All @@ -23,7 +28,7 @@ services:
- FLIPT_DB_URL=mysql://mysql:password@mysql:3306/flipt
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
command: ["./tmp/wait-for-it.sh", "mysql:3306", "--", "./flipt", "--force-migrate"]
command: ["/flipt", "--force-migrate"]

networks:
flipt_network:
8 changes: 0 additions & 8 deletions examples/database/postgres/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion examples/database/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
14 changes: 10 additions & 4 deletions examples/database/postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ version: "3"

services:
postgres:
image: postgres:12
image: postgres:alpine
networks:
- flipt_network
environment:
- POSTGRES_DB=flipt
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 5s
timeout: 5s
retries: 5

flipt:
build: .
image: flipt/flipt:latest
depends_on:
- postgres
postgres:
condition: service_healthy
ports:
- "8080:8080"
networks:
Expand All @@ -22,7 +28,7 @@ services:
- FLIPT_DB_URL=postgres://postgres:password@postgres:5432/flipt?sslmode=disable
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
command: ["./tmp/wait-for-it.sh", "postgres:5432", "--", "./flipt", "--force-migrate"]
command: ["/flipt", "--force-migrate"]

networks:
flipt_network:
2 changes: 1 addition & 1 deletion examples/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To run this example application you'll need:

## Running the Example

1. Run `docker-compose up` from this directory
1. Run `docker compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
1. Create some sample data: Flags/Segments/etc.
1. Open the Prometheus UI (default: [http://localhost:9090/graph](http://localhost:9090/graph))
Expand Down
2 changes: 1 addition & 1 deletion examples/openfeature/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.20
ARG GO_VERSION=1.23

FROM golang:${GO_VERSION}-alpine

Expand Down
Loading
Loading