refactor: 将newEventID函数移动到rabbitMQ
This commit is contained in:
@@ -2,6 +2,8 @@ package rabbitmq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"feedsystem_video_go/internal/config"
|
||||
@@ -104,3 +106,11 @@ func (r *RabbitMQ) PublishJSON(ctx context.Context, exchange string, routingKey
|
||||
Body: b,
|
||||
})
|
||||
}
|
||||
|
||||
func newEventID(n int) (string, error) {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package rabbitmq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
@@ -67,11 +65,3 @@ func (s *SocialMQ) publish(ctx context.Context, action, routingKey string, follo
|
||||
}
|
||||
return s.PublishJSON(ctx, socialExchange, routingKey, evt)
|
||||
}
|
||||
|
||||
func newEventID(n int) (string, error) {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user