This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
forked from raystack/dex
-
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: add dlq to entropy job mapper (WIP)
- Loading branch information
1 parent
c689eb6
commit 82642ff
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,98 @@ | ||
package dlq | ||
|
||
import ( | ||
"fmt" | ||
|
||
entropyv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/entropy/v1beta1" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
|
||
"github.com/goto/dex/entropy" | ||
"github.com/goto/dex/generated/models" | ||
"github.com/goto/dex/internal/server/utils" | ||
) | ||
|
||
func mapToEntropyResource(job *models.DlqJob) (*entropyv1beta1.Resource, error) { | ||
Check failure on line 14 in internal/server/v1/dlq/mapper.go GitHub Actions / golangci-lint
|
||
cfgStruct, err := makeConfigStruct(job) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &entropyv1beta1.Resource{ | ||
Urn: job.Urn, | ||
Kind: entropy.ResourceKindJob, | ||
Name: buildResourceName(job), | ||
Project: job.Project, | ||
Labels: buildResourceLabels(job), | ||
Spec: &entropyv1beta1.ResourceSpec{ | ||
Configs: cfgStruct, | ||
}, | ||
}, nil | ||
} | ||
|
||
func makeConfigStruct(job *models.DlqJob) (*structpb.Value, error) { | ||
Check failure on line 32 in internal/server/v1/dlq/mapper.go GitHub Actions / golangci-lint
|
||
return utils.GoValToProtoStruct(entropy.JobConfig{ | ||
Stopped: job.Stopped, | ||
Replicas: int32(job.Replicas), | ||
Namespace: "", // decide with streaming where to store namespace | ||
Name: "", // decide with streaming job name | ||
Containers: []entropy.JobContainer{ | ||
{ | ||
Name: "dlq", | ||
Image: "test-image", // ask streaming for image name, and also if it can be modified via UI/client | ||
ImagePullPolicy: "Always", | ||
Command: []string{""}, // confirm with streaming team for commands | ||
SecretsVolumes: []entropy.JobSecret{ // confirm with streaming for required secrets | ||
{ | ||
Name: "", | ||
Mount: "", | ||
}, | ||
}, | ||
ConfigMapsVolumes: []entropy.JobConfigMap{ // confirm with streaming for required secrets | ||
{ | ||
Name: "", | ||
Mount: "", | ||
}, | ||
}, | ||
Limits: &entropy.UsageSpec{ | ||
CPU: "", | ||
Memory: "", | ||
}, | ||
Requests: &entropy.UsageSpec{ | ||
CPU: "", | ||
Memory: "", | ||
}, | ||
EnvConfigMaps: []string{}, | ||
EnvVariables: map[string]string{}, | ||
}, | ||
}, | ||
JobLabels: map[string]string{}, | ||
Volumes: []entropy.JobVolume{ | ||
{ | ||
Name: "", | ||
Kind: "", | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func buildResourceLabels(job *models.DlqJob) map[string]string { | ||
Check failure on line 78 in internal/server/v1/dlq/mapper.go GitHub Actions / golangci-lint
|
||
return map[string]string{ | ||
"batch_size": fmt.Sprintf("%d", job.BatchSize), | ||
"blob_batch": fmt.Sprintf("%d", job.BlobBatch), | ||
"num_threads": job.ErrorTypes, | ||
"date": job.Date, | ||
"resource_id": job.ResourceID, | ||
"resource_type": job.ResourceType, | ||
"topic": job.Topic, | ||
} | ||
} | ||
|
||
func buildResourceName(job *models.DlqJob) string { | ||
Check failure on line 90 in internal/server/v1/dlq/mapper.go GitHub Actions / golangci-lint
|
||
return fmt.Sprintf( | ||
"%s-%s-%s-%s", | ||
job.ResourceID, | ||
job.ResourceType, | ||
job.Topic, | ||
job.Date, | ||
) | ||
} |
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