Skip to content

Commit

Permalink
Add interval flag for configuring the pull interval (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
allebacco authored Apr 16, 2021
1 parent 58eb4d4 commit 6b4b7d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ objinsync pull --once s3://bucket/keyprefix ./localdir
To use with [Minio](https://docs.min.io/) instead of S3, you can set
`--s3-endpoint` and `--disable-ssl` flags for `pull` command as you see fit.

The `-i` or `--interval` flags allows to configure the pull time interval, which is 5 seconds by default:

```bash
objinsync pull --interval 20s s3://bucket/keyprefix ./localdir
```

---

Enable debug logs by setting the `DEBUG` environment variable `DEBUG=1 objinsync pull ...`
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
FlagDefaultFileMode = "0664"
FlagS3Endpoint = ""
FlagDisableSSL = false
FlagPullInterval = time.Second * 5

metricsSyncTime = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "objinsync",
Expand Down Expand Up @@ -98,7 +99,7 @@ func main() {
Run: func(cmd *cobra.Command, args []string) {
remoteUri := args[0]
localDir := args[1]
interval := time.Second * 5
interval := FlagPullInterval

puller, err := sync.NewPuller(remoteUri, localDir)
if err != nil {
Expand Down Expand Up @@ -177,6 +178,8 @@ func main() {
&FlagDefaultFileMode, "default-file-mode", "m", "0664", "default mode to use for creating local file")
pullCmd.PersistentFlags().StringVarP(
&FlagS3Endpoint, "s3-endpoint", "", "", "override endpoint to use for remote object store (e.g. minio)")
pullCmd.PersistentFlags().DurationVarP(
&FlagPullInterval, "interval", "i", time.Second * 5, "Interval between remote storage pulls")

rootCmd.AddCommand(pullCmd)
rootCmd.Execute()
Expand Down

0 comments on commit 6b4b7d5

Please sign in to comment.