forked from mtusi2026/mtusi2026lab6
lab6
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -120,9 +121,18 @@ func (m JobMessage) Validate() error {
|
||||
return errors.New("created_at is required")
|
||||
}
|
||||
|
||||
if m.Traceparent != "" && !traceparentPattern.MatchString(m.Traceparent) {
|
||||
return errors.New("traceparent does not match W3C format")
|
||||
}
|
||||
if len(m.Tracestate) > 512 {
|
||||
return errors.New("tracestate is too long")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var traceparentPattern = regexp.MustCompile(`^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$`)
|
||||
|
||||
func (m JobMessage) MarshalPayload() ([]byte, error) {
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user