-
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.
add domain folder; add requestId middleware; improve logging middleware
Signed-off-by: Lukas <lukas.jarosch@mail.com>
- Loading branch information
1 parent
d5952f5
commit e59753a
Showing
25 changed files
with
283 additions
and
50 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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,42 @@ | ||
package generate | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gobuffalo/packr" | ||
"github.com/lukasjarosch/godin/internal/bundle" | ||
"github.com/lukasjarosch/godin/internal/template" | ||
"github.com/vetcher/go-astra/types" | ||
) | ||
|
||
type AmqpSubscriberHandler struct { | ||
BaseGenerator | ||
} | ||
|
||
func NewAMQPSubscriberHandler(sub template.Subscriber, box packr.Box, serviceInterface *types.Interface, ctx template.Context, options ...Option) *AmqpSubscriberHandler { | ||
defaults := &Options{ | ||
Context: ctx, | ||
Overwrite: true, | ||
IsGoSource: true, | ||
Template: "amqp_subscriber_handler", | ||
TargetFile: fmt.Sprintf("internal/service/subscriber/%s", bundle.SubscriberFileName(sub.Subscription.Topic)), | ||
} | ||
|
||
for _, opt := range options { | ||
opt(defaults) | ||
} | ||
|
||
return &AmqpSubscriberHandler{ | ||
BaseGenerator{ | ||
box: box, | ||
iface: serviceInterface, | ||
opts: defaults, | ||
}, | ||
} | ||
} | ||
|
||
func (s *AmqpSubscriberHandler) Update() error { | ||
if s.TargetExists() { | ||
return nil | ||
} | ||
return s.GenerateFull() | ||
} |
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,38 @@ | ||
package generate | ||
|
||
import ( | ||
"github.com/gobuffalo/packr" | ||
"github.com/lukasjarosch/godin/internal/template" | ||
"github.com/vetcher/go-astra/types" | ||
) | ||
|
||
type AmqpSubscriber struct { | ||
BaseGenerator | ||
} | ||
|
||
func NewAMQPSubscriber(box packr.Box, serviceInterface *types.Interface, ctx template.Context, options ...Option) *AmqpSubscriber { | ||
defaults := &Options{ | ||
Context: ctx, | ||
Overwrite: true, | ||
IsGoSource: true, | ||
Template: "amqp_subscriber_init", | ||
TargetFile: "internal/service/subscriber/initialize.go", | ||
} | ||
|
||
for _, opt := range options { | ||
opt(defaults) | ||
} | ||
|
||
return &AmqpSubscriber{ | ||
BaseGenerator{ | ||
box: box, | ||
iface: serviceInterface, | ||
opts: defaults, | ||
}, | ||
} | ||
} | ||
|
||
// Update will call GenerateFull. The cmd/main.go cannot be updated. | ||
func (s *AmqpSubscriber) Update() error { | ||
return s.GenerateFull() | ||
} |
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
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
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
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,34 @@ | ||
// Code generated by Godin v{{ .Godin.Version }}; DO NOT EDIT. | ||
package subscriber | ||
|
||
import ( | ||
godinAMQP "github.com/lukasjarosch/godin/pkg/amqp" | ||
"github.com/go-godin/log" | ||
"github.com/streadway/amqp" | ||
) | ||
|
||
{{- $serviceName := title .Service.Name -}} | ||
|
||
{{ range .Service.Subscriber }} | ||
func Init{{ .Handler }}(channel *amqp.Channel, svc service.{{ $serviceName }}, logger log.Logger) (subscriber godinAMQP.Subscriber, err error) { | ||
subscription := &godinAMQP.Subscription{ | ||
Exchange: "{{ .Subscription.Exchange }}", | ||
AutoAck: {{ .Subscription.AutoAck }}, | ||
Queue: godinAMQP.SubscriptionQueue{ | ||
AutoDelete: {{ .Subscription.Queue.AutoDelete }}, | ||
Durable: {{ .Subscription.Queue.Durable }}, | ||
Exclusive: {{ .Subscription.Queue.Exclusive }}, | ||
Name: "{{ .Subscription.Queue.Name }}", | ||
NoWait: {{ .Subscription.Queue.NoWait }}, | ||
}, | ||
Topic: "{{ .Subscription.Topic }}", | ||
} | ||
subscriber = godinAMQP.NewSubscriber(channel, subscription) | ||
if err = subscriber.Subscribe({{ .Handler }}(logger, svc)); err != nil { | ||
logger.Error("failed to subscribe to {{ .Subscription.Topic }}", "err", err) | ||
return subscriber, err | ||
} | ||
logger.Info("subscribed to topic '{{ .Subscription.Topic }}'", "topic", subscription.Topic, "queue", subscription.Queue.Name, "exchange", subscription.Exchange) | ||
return subscriber, nil | ||
} | ||
{{ end }} |
Oops, something went wrong.