mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
95 lines
2.9 KiB
Go
95 lines
2.9 KiB
Go
package deployment
|
|
|
|
import (
|
|
"cmp"
|
|
"context"
|
|
"sync"
|
|
|
|
"go.temporal.io/sdk/activity"
|
|
deploymentspb "go.temporal.io/server/api/deployment/v1"
|
|
"go.temporal.io/server/api/matchingservice/v1"
|
|
"go.temporal.io/server/common/namespace"
|
|
"go.temporal.io/server/common/resource"
|
|
)
|
|
|
|
type (
|
|
DeploymentActivities struct {
|
|
namespace *namespace.Namespace
|
|
deploymentClient DeploymentStoreClient
|
|
matchingClient resource.MatchingClient
|
|
}
|
|
)
|
|
|
|
func (a *DeploymentActivities) StartDeploymentSeriesWorkflow(ctx context.Context, input *deploymentspb.StartDeploymentSeriesRequest) error {
|
|
logger := activity.GetLogger(ctx)
|
|
logger.Info("starting deployment series workflow", "seriesName", input.SeriesName)
|
|
identity := "deployment workflow " + activity.GetInfo(ctx).WorkflowExecution.ID
|
|
return a.deploymentClient.StartDeploymentSeries(ctx, a.namespace, input.SeriesName, identity, input.RequestId)
|
|
}
|
|
|
|
func (a *DeploymentActivities) SyncUserData(ctx context.Context, input *deploymentspb.SyncUserDataRequest) (*deploymentspb.SyncUserDataResponse, error) {
|
|
logger := activity.GetLogger(ctx)
|
|
|
|
errs := make(chan error)
|
|
|
|
var lock sync.Mutex
|
|
maxVersionByName := make(map[string]int64)
|
|
|
|
for _, sync := range input.Sync {
|
|
go func() {
|
|
logger.Info("syncing task queue userdata for deployment", "taskQueue", sync.Name, "type", sync.Type)
|
|
res, err := a.matchingClient.SyncDeploymentUserData(ctx, &matchingservice.SyncDeploymentUserDataRequest{
|
|
NamespaceId: a.namespace.ID().String(),
|
|
TaskQueue: sync.Name,
|
|
TaskQueueType: sync.Type,
|
|
Deployment: input.Deployment,
|
|
Data: sync.Data,
|
|
})
|
|
if err != nil {
|
|
logger.Error("syncing task queue userdata", "taskQueue", sync.Name, "type", sync.Type, "error", err)
|
|
} else {
|
|
lock.Lock()
|
|
maxVersionByName[sync.Name] = max(maxVersionByName[sync.Name], res.Version)
|
|
lock.Unlock()
|
|
}
|
|
errs <- err
|
|
}()
|
|
}
|
|
|
|
var err error
|
|
for range input.Sync {
|
|
err = cmp.Or(err, <-errs)
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &deploymentspb.SyncUserDataResponse{TaskQueueMaxVersions: maxVersionByName}, nil
|
|
}
|
|
|
|
func (a *DeploymentActivities) CheckUserDataPropagation(ctx context.Context, input *deploymentspb.CheckUserDataPropagationRequest) error {
|
|
logger := activity.GetLogger(ctx)
|
|
|
|
errs := make(chan error)
|
|
|
|
for name, version := range input.TaskQueueMaxVersions {
|
|
go func() {
|
|
logger.Info("waiting for userdata propagation", "taskQueue", name, "version", version)
|
|
_, err := a.matchingClient.CheckTaskQueueUserDataPropagation(ctx, &matchingservice.CheckTaskQueueUserDataPropagationRequest{
|
|
NamespaceId: a.namespace.ID().String(),
|
|
TaskQueue: name,
|
|
Version: version,
|
|
})
|
|
if err != nil {
|
|
logger.Error("waiting for userdata", "taskQueue", name, "type", version, "error", err)
|
|
}
|
|
errs <- err
|
|
}()
|
|
}
|
|
|
|
var err error
|
|
for range input.TaskQueueMaxVersions {
|
|
err = cmp.Or(err, <-errs)
|
|
}
|
|
return err
|
|
}
|