Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Get the local file sender work when running locally through docker co…
Browse files Browse the repository at this point in the history
…mpose
  • Loading branch information
halprin committed May 22, 2024
1 parent 3f4f345 commit f34993a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ dockerBuild:

dockerRun:
docker run -it reportstream-sftp-ingestion

dockerComposeRun:
docker compose up --build
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ services:
rs-sftp:
build: .
environment:
AZURE_BLOB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://sftp-Azurite:10000/devstoreaccount1;
AZURE_BLOB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://sftp-Azurite:10000/devstoreaccount1; # pragma: allowlist secret
ENV: local
# Uncomment the line below to call local report stream. Otherwise we'll use a mock response
#REPORT_STREAM_URL_PREFIX: http://localhost:7071
volumes:
# map to Azurite data objects to the build directory
- ./localdata/reportstream:/localdata
ports:
- "9090:9090" # default api endpoint port
platform: linux/amd64
Expand All @@ -31,4 +34,4 @@ services:


networks:
sftp:
sftp:
15 changes: 8 additions & 7 deletions src/local/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ type FileSender struct {
}

func (receiver FileSender) SendMessage(message []byte) (string, error) {
//dir := "localdata"
//err := os.MkdirAll(dir, 0755)
//if err != nil {
// return "", err
//}
folder := "localdata"

err := os.MkdirAll(folder, 0755)
if err != nil {
return "", err
}

randomUuid := uuid.NewString()

filePath := filepath.Join("localdata", fmt.Sprintf("%s.txt", randomUuid))
err := os.WriteFile(filePath, message, 0644) // permissions = owner read/write, group read, other read
filePath := filepath.Join(folder, fmt.Sprintf("%s.txt", randomUuid))
err = os.WriteFile(filePath, message, 0644) // permissions = owner read/write, group read, other read
if err != nil {
return "", err
}
Expand Down

0 comments on commit f34993a

Please sign in to comment.