-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update main.go to load S3 file from a different endpoint
- Loading branch information
1 parent
2cedeb7
commit 3d48b32
Showing
8 changed files
with
60 additions
and
157 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,7 @@ | ||
## Usage | ||
|
||
Use the following path as the input filepath. | ||
|
||
``` | ||
s3://default/data.json?region=us-west-2&endpoint=s3.amazonaws.com&access_key=********************&secret_key=**************************************** | ||
``` |
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,34 @@ | ||
package main | ||
|
||
import ( | ||
"log/slog" | ||
|
||
"github.com/WangYihang/gojob/pkg/utils" | ||
"github.com/WangYihang/uio" | ||
) | ||
|
||
func main() { | ||
resultFd, err := uio.Open("s3://uio/output.txt" + | ||
"?endpoint=127.0.0.1:9000" + | ||
"&access_key=minioadmin" + | ||
"&secret_key=minioadmin" + | ||
"&insecure=true" + | ||
"&mode=write", | ||
) | ||
if err != nil { | ||
slog.Error("failed to open result file", slog.String("error", err.Error())) | ||
return | ||
} | ||
defer resultFd.Close() | ||
for line := range utils.Cat( | ||
"s3://uio/input.txt" + | ||
"?endpoint=127.0.0.1:9000" + | ||
"&access_key=minioadmin" + | ||
"&secret_key=minioadmin" + | ||
"&insecure=true" + | ||
"&mode=read", | ||
) { | ||
slog.Info("s3", slog.String("line", line)) | ||
resultFd.Write([]byte(line + "\n")) | ||
} | ||
} |
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
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
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