Skip to content

Commit e873509

Browse files
En/add readme in examples (#329)
--------- Co-authored-by: Srijan Rastogi <[email protected]> Co-authored-by: srijan-27 <[email protected]>
1 parent 06af22a commit e873509

File tree

9 files changed

+143
-0
lines changed

9 files changed

+143
-0
lines changed

examples/grpc-server/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# GRPC Server Example
2+
3+
This GoFr example demonstrates a simple grpc server.
4+
5+
### To run the example use the command below:
6+
```console
7+
go run main.go
8+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Redis Example
2+
3+
This GoFr example demonstrates the use of redis as datasource through a simple http server.
4+
5+
### To run the example follow the steps below:
6+
7+
- Run the docker image of redis
8+
```console
9+
docker run --name gofr-redis -p 2002:6379 -d redis:7.0.5
10+
```
11+
12+
- Now run the example
13+
```console
14+
go run main.go
15+
```

examples/http-server/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# HTTP Server Example
2+
3+
This GoFr example demonstrates a simple http server which supports redis and mysql as datasources.
4+
5+
### To run the example follow the steps below:
6+
7+
- Run the docker image of redis
8+
```console
9+
docker run --name gofr-redis -p 2002:6379 -d redis:7.0.5
10+
```
11+
12+
- Run the docker image of mysql
13+
```console
14+
docker run --name gofr-mysql -e MYSQL_ROOT_PASSWORD=password -p 2001:3306 -d mysql:8.0.30
15+
```
16+
17+
NOTE: Please create a DB named `test` as mentioned in `DB_NAME` using above mysql image.
18+
19+
- Now run the example
20+
```console
21+
go run main.go
22+
```

examples/sample-cmd/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CMD Example
2+
3+
This GoFr example demonstrates a simple CMD application.
4+
5+
### To run the example use the command below:
6+
```console
7+
go run main.go
8+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Custom Metrics Example
2+
3+
This GoFr example demonstrates the use of custom metrics through a simple http server that creates and populate metrics.
4+
5+
### To run the example use the command below:
6+
```console
7+
go run main.go
8+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Http-Service Example
2+
3+
This GoFr example demonstrates an inter-service http communication along with circuit-breaker as well as
4+
service health config addition.
5+
6+
User can use the `AddHTTPService` method to add an http service and then later get it using `GetHTTPService("service-name")`
7+
8+
### To run the example follow the below steps:
9+
- Make sure your other service and health endpoint is ready and up on the given address.
10+
- Now run the example using below command :
11+
12+
```console
13+
go run main.go
14+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Migrations Example
2+
3+
This GoFr example demonstrates the use of `migrations` through a simple http server using mysql and redis.
4+
5+
### To run the example follow the below steps:
6+
- Run the docker image of mysql and redis
7+
8+
```console
9+
docker run --name gofr-mysql -e MYSQL_ROOT_PASSWORD=password -p 2001:3306 -d mysql:8.0.30
10+
docker run --name gofr-redis -p 2002:6379 -d redis:7.0.5
11+
```
12+
13+
- Now run the example using below command :
14+
15+
```console
16+
go run main.go
17+
```

examples/using-publisher/readme.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Publisher Example
2+
3+
This GoFr example demonstrates a simple Publisher that publishes to the given topic when an http request is made to it's
4+
matching route.
5+
6+
### To run the example follow the below steps:
7+
8+
- Run the docker image of kafka and zookeeper and ensure that your provided topics are created before publishing
9+
```console
10+
docker run --rm -d -p 2181:2181 -p 443:2008 -p 2008:2008 -p 2009:2009 \
11+
--env ADVERTISED_LISTENERS=PLAINTEXT://localhost:443,INTERNAL://localhost:2009 \
12+
--env LISTENERS=PLAINTEXT://0.0.0.0:2008,INTERNAL://0.0.0.0:2009 \
13+
--env SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,INTERNAL:PLAINTEXT \
14+
--env INTER_BROKER=INTERNAL \
15+
--env KAFKA_CREATE_TOPICS="test-topic,test:36:1,krisgeus:12:1:compact" \
16+
--name gofr-kafka \
17+
krisgeus/docker-kafka
18+
```
19+
20+
- Now run the example using below command :
21+
22+
```console
23+
go run main.go
24+
```
25+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Subscriber Example
2+
3+
This GoFr example demonstrates a simple Subscriber that subscribes asynchronously to a given topic and commits based
4+
on the handler response.
5+
6+
7+
### To run the example follow the below steps:
8+
9+
- Run the docker image of kafka and zookeeper and ensure that your provided topics are created before subscribing.
10+
```console
11+
docker run --rm -d -p 2181:2181 -p 443:2008 -p 2008:2008 -p 2009:2009 \
12+
--env ADVERTISED_LISTENERS=PLAINTEXT://localhost:443,INTERNAL://localhost:2009 \
13+
--env LISTENERS=PLAINTEXT://0.0.0.0:2008,INTERNAL://0.0.0.0:2009 \
14+
--env SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,INTERNAL:PLAINTEXT \
15+
--env INTER_BROKER=INTERNAL \
16+
--env KAFKA_CREATE_TOPICS="test-topic,test:36:1,krisgeus:12:1:compact" \
17+
--name gofr-kafka \
18+
krisgeus/docker-kafka
19+
```
20+
21+
- Now run the example using below command :
22+
23+
```console
24+
go run main.go
25+
```
26+

0 commit comments

Comments
 (0)