fix: issues
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
"git.ipao.vip/rogeecn/atom/contracts"
|
||||
"git.ipao.vip/rogeecn/atom/utils/opt"
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
)
|
||||
|
||||
@@ -46,3 +48,18 @@ func (ps *PubSub) Handle(
|
||||
) {
|
||||
ps.Router.AddHandler(handlerName, consumerTopic, ps.Subscriber, publisherTopic, ps.Publisher, handler)
|
||||
}
|
||||
|
||||
// publish
|
||||
func (ps *PubSub) Publish(e contracts.EventPublisher) error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
payload, err := e.Marshal()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := message.NewMessage(watermill.NewUUID(), payload)
|
||||
return ps.Publisher.Publish(e.Topic(), msg)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package event
|
||||
|
||||
import (
|
||||
sqlDB "database/sql"
|
||||
@@ -51,4 +51,11 @@ func (c *Config) format() {
|
||||
c.Env = "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
if c.EndpointGRPC == "" {
|
||||
c.EndpointGRPC = os.Getenv("OTEL_ENDPOINT_GRPC")
|
||||
if c.EndpointGRPC == "" {
|
||||
c.EndpointGRPC = "localhost:4317"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ var (
|
||||
)
|
||||
|
||||
func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
return tracer.Start(ctx, spanName, opts...)
|
||||
return tracer.Start(ctx, spanName)
|
||||
}
|
||||
|
||||
func Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
|
||||
Reference in New Issue
Block a user