Skip to content

Commit

Permalink
chore: remove unused options
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Jul 11, 2024
1 parent dd5ddb7 commit a6b2de5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
12 changes: 5 additions & 7 deletions pubsubjobs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

// pipeline rabbitmq info
const (
skipTopicKey string = "skip_topic_declaration"
projectIDKey string = "project_id"
deadLetterTopic string = "dead_letter_topic"
topicKey string = "topic"
Expand All @@ -21,12 +20,11 @@ type config struct {
Insecure bool `mapstructure:"insecure"`

// local
SkipTopicDeclaration bool `mapstructure:"skip_topic_declaration"`
ProjectID string `mapstructure:"project_id"`
DeadLetterTopic string `mapstructure:"dead_letter_topic"`
Topic string `mapstructure:"topic"`
MaxDeliveryAttempts int `mapstructure:"max_delivery_attempts"`
Priority int `mapstructure:"priority"`
ProjectID string `mapstructure:"project_id"`
DeadLetterTopic string `mapstructure:"dead_letter_topic"`
Topic string `mapstructure:"topic"`
MaxDeliveryAttempts int `mapstructure:"max_delivery_attempts"`
Priority int `mapstructure:"priority"`
}

func (c *config) InitDefaults() error {
Expand Down
23 changes: 10 additions & 13 deletions pubsubjobs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type Driver struct {
pipeline atomic.Pointer[jobs.Pipeline]
tracer *sdktrace.TracerProvider
prop propagation.TextMapPropagator
skipDeclare bool
topic string
dltopic string
sub string
Expand Down Expand Up @@ -131,7 +130,6 @@ func FromConfig(tracer *sdktrace.TracerProvider, configKey string, pipe jobs.Pip
tracer: tracer,
prop: prop,
log: log,
skipDeclare: conf.SkipTopicDeclaration,
topic: conf.Topic,
dltopic: conf.DeadLetterTopic,
maxDeliveryAttempts: conf.MaxDeliveryAttempts,
Expand Down Expand Up @@ -181,7 +179,6 @@ func FromPipeline(tracer *sdktrace.TracerProvider, pipe jobs.Pipeline, log *zap.
conf.Topic = pipe.String(topicKey, "")
conf.DeadLetterTopic = pipe.String(deadLetterTopic, "")
conf.MaxDeliveryAttempts = pipe.Int(maxDeliveryAttempts, 10)
conf.SkipTopicDeclaration = pipe.Bool(skipTopicKey, false)
conf.Priority = pipe.Int(priorityKey, 10)

err = conf.InitDefaults()
Expand All @@ -208,14 +205,13 @@ func FromPipeline(tracer *sdktrace.TracerProvider, pipe jobs.Pipeline, log *zap.
eventBus, id := events.NewEventBus()

jb := &Driver{
prop: prop,
tracer: tracer,
log: log,
pq: pq,
skipDeclare: conf.SkipTopicDeclaration,
topic: conf.Topic,
sub: pipe.Name(),
gclient: gclient,
prop: prop,
tracer: tracer,
log: log,
pq: pq,
topic: conf.Topic,
sub: pipe.Name(),
gclient: gclient,

// events
eventsCh: eventsCh,
Expand Down Expand Up @@ -377,7 +373,8 @@ func (d *Driver) manageSubscriptions() error {
// topic would be nil if it already exists
d.gtopic = d.gclient.Topic(d.topic)
}
d.log.Debug("created topic", zap.String("topic", d.gtopic.String()))

d.log.Debug("created/used topic", zap.String("topic", d.gtopic.String()))

// check or create a Dead Letter Topic
var dltopic *pubsub.Topic
Expand All @@ -393,7 +390,7 @@ func (d *Driver) manageSubscriptions() error {
dltopic = d.gclient.Topic(d.dltopic)
}

d.log.Debug("created dead letter topic", zap.String("topic", dltopic.String()))
d.log.Debug("created/used dead letter topic", zap.String("topic", dltopic.String()))
}

d.gsub, err = d.gclient.CreateSubscription(ctx, d.sub, pubsub.SubscriptionConfig{
Expand Down
2 changes: 0 additions & 2 deletions tests/configs/.rr-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ jobs:
config:
project_id: test
topic: rrTopic1
skip_topic_declaration: false
dead_letter_topic: "dead-letter-topic"

test-2:
driver: google_pub_sub
config:
project_id: test
topic: rrTopic2
skip_topic_declaration: false
consume: ["test-1", "test-2"]
12 changes: 6 additions & 6 deletions tests/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ func DeclarePipe(topic string, address string, pipeline string) func(t *testing.
client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn))

pipe := &jobsProto.DeclareRequest{Pipeline: map[string]string{
"driver": "google_pub_sub",
"name": pipeline,
"priority": "3",
"topic": topic,
"skip_topic_declaration": "false",
"project_id": "test",
"driver": "google_pub_sub",
"name": pipeline,
"priority": "3",
"topic": topic,
"dead_letter_topic": "dead_letter_topic",
"project_id": "test",
}}

er := &jobsProto.Empty{}
Expand Down

0 comments on commit a6b2de5

Please sign in to comment.