MCPcopy
hub / github.com/nats-io/nats.go / publishMeta

Function publishMeta

jetstream/object.go:979–998  ·  view source on GitHub ↗
(ctx context.Context, info *ObjectInfo, js *jetStream)

Source from the content-addressed store, hash-verified

977}
978
979func publishMeta(ctx context.Context, info *ObjectInfo, js *jetStream) error {
980 // marshal the object into json, don't store an actual time
981 info.ModTime = time.Time{}
982 data, err := json.Marshal(info)
983 if err != nil {
984 return err
985 }
986
987 // Prepare and publish the message.
988 mm := nats.NewMsg(fmt.Sprintf(objMetaPreTmpl, info.Bucket, encodeName(info.ObjectMeta.Name)))
989 mm.Header.Set(MsgRollup, MsgRollupSubject)
990 mm.Data = data
991 if _, err := js.PublishMsg(ctx, mm); err != nil {
992 return err
993 }
994
995 // set the ModTime in case it's returned to the user, even though it's not the correct time.
996 info.ModTime = time.Now().UTC()
997 return nil
998}
999
1000// AddLink will add a link to another object if it's not deleted and not another link
1001// name is the name of this link object

Callers 4

DeleteMethod · 0.70
AddLinkMethod · 0.70
AddBucketLinkMethod · 0.70
UpdateMetaMethod · 0.70

Calls 3

encodeNameFunction · 0.70
SetMethod · 0.65
PublishMsgMethod · 0.65

Tested by

no test coverage detected