-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20b5880
commit 1b9c1f6
Showing
19 changed files
with
355 additions
and
15 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,27 @@ | ||
package activities | ||
|
||
import ( | ||
"cloud.google.com/go/pubsub" | ||
"context" | ||
"encoding/json" | ||
) | ||
|
||
func PubsubPublish(ctx context.Context, data any) error { | ||
client, err := pubsub.NewClient(ctx, "btv-platform-prod-2") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
topic := client.Topic("background_worker") | ||
defer topic.Stop() | ||
|
||
msg, err := json.Marshal(data) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = topic.Publish(ctx, &pubsub.Message{ | ||
Data: msg, | ||
}).Get(ctx) | ||
return err | ||
} |
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 activities | ||
|
||
import ( | ||
"context" | ||
"github.com/bcc-code/bccm-flows/services/rclone" | ||
"go.temporal.io/sdk/activity" | ||
"time" | ||
) | ||
|
||
type RcloneUploadDirInput struct { | ||
Source string | ||
Destination string | ||
} | ||
|
||
func RcloneUploadDir(ctx context.Context, input RcloneUploadDirInput) (bool, error) { | ||
activity.RecordHeartbeat(ctx, "Rclone Upload Dir") | ||
|
||
res, err := rclone.CopyDir(input.Source, input.Destination) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
for { | ||
job, err := rclone.CheckJobStatus(res.JobID) | ||
if err != nil { | ||
return false, err | ||
} | ||
activity.RecordHeartbeat(ctx, job) | ||
if job == nil { | ||
return false, nil | ||
} | ||
if job.Finished { | ||
return job.Success, nil | ||
} | ||
time.Sleep(time.Second * 10) | ||
} | ||
} |
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
Oops, something went wrong.