24 lines
539 B
Go
24 lines
539 B
Go
// Package id provides internal identifier generators used by Mail Service.
|
|
package id
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"galaxy/mail/internal/domain/common"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Generator builds UUID-backed internal delivery identifiers.
|
|
type Generator struct{}
|
|
|
|
// NewDeliveryID returns one new UUID v4 delivery identifier.
|
|
func (Generator) NewDeliveryID() (common.DeliveryID, error) {
|
|
value, err := uuid.NewRandom()
|
|
if err != nil {
|
|
return "", fmt.Errorf("new delivery id: %w", err)
|
|
}
|
|
|
|
return common.DeliveryID(value.String()), nil
|
|
}
|