Skip to content

Commit

Permalink
chore: rm commited dbs; use flipt import in examples; fix examples (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps authored Aug 7, 2023
1 parent 834924e commit 99564ea
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/basic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ COPY . .

RUN go mod tidy

ENTRYPOINT ["go", "run", "-tags", "example", "main.go"]
CMD ["go", "run", "-tags", "example", "main.go"]
23 changes: 19 additions & 4 deletions examples/basic/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
version: "3"

services:
init:
image: flipt/flipt:latest
command: ["./flipt", "import", "flipt.yml"]
environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "./flipt.yml:/flipt.yml"
- "flipt_data:/var/opt/flipt"

flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
command: ["./flipt"]
depends_on:
- init
ports:
- "8080:8080"
- "9000:9000"
Expand All @@ -13,16 +25,19 @@ services:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "./flipt.db:/var/opt/flipt/flipt.db"
- "flipt_data:/var/opt/flipt"

example:
build: .
depends_on:
- flipt
ports:
- "8000:8000"
networks:
- flipt_network
depends_on:
- flipt

volumes:
flipt_data:

networks:
flipt_network:
Binary file removed examples/basic/flipt.db
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/basic/flipt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace: default
flags:
- key: example
name: Example
description: An example flag
1 change: 0 additions & 1 deletion examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func main() {

log.Println("Flipt UI available at http://localhost:8080")
log.Println("Client UI available at http://localhost:8000")
log.Println("Jaeger UI available at http://localhost:16686")
log.Printf("Flag Key: %q\n", flagKey)
log.Fatal(http.ListenAndServe(":8000", h))
}
4 changes: 2 additions & 2 deletions examples/nextjs/components/Greeting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Greeting() {

useEffect(() => {
async function fetchData() {
let language = "french";
let language = "fr";
try {
const evaluation = await flipt.evaluate.evaluate({
flagKey: "language",
Expand All @@ -24,7 +24,7 @@ export default function Greeting() {
}

let greeting =
language == "spanish"
language == "es"
? "Hola, from Next.js client-side"
: "Bonjour, from Next.js client-side";

Expand Down
21 changes: 17 additions & 4 deletions examples/nextjs/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,33 @@ services:
networks:
- flipt_network

init:
image: flipt/flipt:latest
command: ["./flipt", "import", "flipt.yml"]
environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "./flipt.yml:/flipt.yml"
- "flipt_data:/var/opt/flipt"

flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
command: ["./flipt"]
depends_on:
- init
ports:
- "8080:8080"
environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- type: bind
source: ./flipt.db
target: /var/opt/flipt/flipt.db
- "flipt_data:/var/opt/flipt"
networks:
- flipt_network

volumes:
flipt_data:

networks:
flipt_network:
Binary file removed examples/nextjs/flipt.db
Binary file not shown.
29 changes: 29 additions & 0 deletions examples/nextjs/flipt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace: default
flags:
- key: language
name: Language
description: The language of the user
enabled: true
variants:
- key: es
name: Spanish
description: Habla español
- key: en
name: English
description: The user speaks English
- key: fr
name: French
description: Parle français
rules:
- segment: all
distributions:
- variant: es
rollout: 33.34
- variant: en
rollout: 33.33
- variant: fr
rollout: 33.33
segments:
- key: all
name: all
match_type: ALL_MATCH_TYPE
4 changes: 2 additions & 2 deletions examples/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const client = new FliptApiClient({
});

export async function getServerSideProps() {
let language = "english";
let language = "en";
try {
const evaluation = await client.evaluate.evaluate({
flagKey: "language",
Expand All @@ -54,7 +54,7 @@ export async function getServerSideProps() {
}

const greeting =
language == "spanish"
language == "es"
? "Hola, from Next.js server-side"
: "Hello, from Next.js server-side";

Expand Down
16 changes: 15 additions & 1 deletion examples/openfeature/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ services:
environment:
- COLLECTOR_ZIPKIN_HTTP_PORT=9411

init:
image: flipt/flipt:latest
command: ["./flipt", "import", "flipt.yml"]
environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "./flipt.yml:/flipt.yml"
- "flipt_data:/var/opt/flipt"

flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
depends_on:
- init
- jaeger
ports:
- "8080:8080"
Expand All @@ -26,7 +37,7 @@ services:
- FLIPT_TRACING_JAEGER_HOST=jaeger
- FLIPT_META_TELEMETRY_ENABLED=false
volumes:
- "./flipt.db:/var/opt/flipt/flipt.db"
- "flipt_data:/var/opt/flipt"

example:
build: .
Expand All @@ -37,5 +48,8 @@ services:
networks:
- flipt_network

volumes:
flipt_data:

networks:
flipt_network:
Binary file removed examples/openfeature/flipt.db
Binary file not shown.
29 changes: 29 additions & 0 deletions examples/openfeature/flipt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace: default
flags:
- key: language
name: Language
description: The language of the user
enabled: true
variants:
- key: es
name: Spanish
description: Habla español
- key: en
name: English
description: The user speaks English
- key: fr
name: French
description: Parle français
rules:
- segment: all
distributions:
- variant: es
rollout: 33.34
- variant: en
rollout: 33.33
- variant: fr
rollout: 33.33
segments:
- key: all
name: all
match_type: ALL_MATCH_TYPE
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38
github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI=
github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2ev3xfyagutxiPw=
github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/hashicorp/consul/api v1.20.0/go.mod h1:nR64eD44KQ59Of/ECwt2vUmIK2DKsDzAwTmwmLl8Wpo=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
Expand Down

0 comments on commit 99564ea

Please sign in to comment.