Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat: add dlq to entropy job mapper (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
StewartJingga committed Sep 29, 2023
1 parent c689eb6 commit 82642ff
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
6 changes: 6 additions & 0 deletions generated/models/dlq_job.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions internal/server/v1/dlq/mapper.go
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

View workflow job for this annotation

GitHub Actions / golangci-lint

`mapToEntropyResource` is unused (deadcode)

Check failure on line 14 in internal/server/v1/dlq/mapper.go

View workflow job for this annotation

GitHub Actions / golangci-lint

`mapToEntropyResource` is unused (deadcode)
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

View workflow job for this annotation

GitHub Actions / golangci-lint

func `makeConfigStruct` is unused (unused)

Check failure on line 32 in internal/server/v1/dlq/mapper.go

View workflow job for this annotation

GitHub Actions / golangci-lint

func `makeConfigStruct` is unused (unused)
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

View workflow job for this annotation

GitHub Actions / golangci-lint

func `buildResourceLabels` is unused (unused)

Check failure on line 78 in internal/server/v1/dlq/mapper.go

View workflow job for this annotation

GitHub Actions / golangci-lint

func `buildResourceLabels` is unused (unused)
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

View workflow job for this annotation

GitHub Actions / golangci-lint

func `buildResourceName` is unused (unused)

Check failure on line 90 in internal/server/v1/dlq/mapper.go

View workflow job for this annotation

GitHub Actions / golangci-lint

func `buildResourceName` is unused (unused)
return fmt.Sprintf(
"%s-%s-%s-%s",
job.ResourceID,
job.ResourceType,
job.Topic,
job.Date,
)
}
4 changes: 4 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,10 @@ definitions:
date:
type: string
example: "2012-10-30"
stopped:
type: boolean
replicas:
type: integer
status:
type: string
enum:
Expand Down

0 comments on commit 82642ff

Please sign in to comment.