-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from datasage-io/AK-8428
AK-8428 Added test code
- Loading branch information
Showing
5 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
all: run-kafka-server run-grpc-server | ||
|
||
run-kafka-server: | ||
docker-compose -f ./resources/docker-compose.yaml up -d | ||
docker exec broker kafka-topics --bootstrap-server broker:9092 --create --topic datasage-logs | ||
|
||
run-grpc-server: | ||
go run server/grpc_server.go | ||
|
||
send-log-to-endpoint: | ||
curl --header "Content-Type: application/json" --request POST --data '{"DataDomainID":"5", "Database":"accuknox","Operation":"select", "OperationDetails":"none", "Timestamp":"2022-06-17T09:35:38Z","User":"ada_demo_user"}' http://127.0.0.1:8080/log | ||
|
||
demo: | ||
go run main.go | ||
|
||
clean: | ||
docker-compose -f ./resources/docker-compose.yaml down | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
version: '3' | ||
services: | ||
zookeeper: | ||
image: confluentinc/cp-zookeeper:7.0.1 | ||
container_name: zookeeper | ||
environment: | ||
ZOOKEEPER_CLIENT_PORT: 2181 | ||
ZOOKEEPER_TICK_TIME: 2000 | ||
|
||
broker: | ||
image: confluentinc/cp-kafka:7.0.1 | ||
container_name: broker | ||
ports: | ||
# To learn about configuring Kafka for access across networks see | ||
# https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/ | ||
- "9092:9092" | ||
depends_on: | ||
- zookeeper | ||
environment: | ||
KAFKA_BROKER_ID: 1 | ||
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT | ||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092 | ||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | ||
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"net" | ||
|
||
config "github.com/datasage-io/datasage/src/integrations/grpc_config" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type server struct { | ||
config.UnimplementedDataSageServerServer | ||
} | ||
|
||
func (s *server) LogSend(ctx context.Context, in *config.Log) (*config.Null, error) { | ||
log.Printf("GRPC: Receive message body from client: %s", in.Body) | ||
return &config.Null{}, nil | ||
} | ||
|
||
func RunGRPCServer() { | ||
listen, err := net.Listen("tcp", ":2222") | ||
if err != nil { | ||
log.Fatalf("failed to listen: %v", err) | ||
} | ||
grpcServer := grpc.NewServer() | ||
fmt.Println("gRPC Server listening on :2222") | ||
config.RegisterDataSageServerServer(grpcServer, &server{}) | ||
if err := grpcServer.Serve(listen); err != nil { | ||
log.Fatalf("failed to serve: %s", err) | ||
} | ||
} | ||
|
||
func main() { | ||
RunGRPCServer() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/datasage-io/datasage/src/integrations" | ||
) | ||
|
||
func main() { | ||
integrations.RunServer() | ||
} |