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

Method Delete

object.go:711–732  ·  view source on GitHub ↗

Delete will delete the object.

(name string)

Source from the content-addressed store, hash-verified

709
710// Delete will delete the object.
711func (obs *obs) Delete(name string) error {
712 // Grab meta info.
713 info, err := obs.GetInfo(name, GetObjectInfoShowDeleted())
714 if err != nil {
715 return err
716 }
717 if info.NUID == _EMPTY_ {
718 return ErrBadObjectMeta
719 }
720
721 // Place a rollup delete marker and publish the info
722 info.Deleted = true
723 info.Size, info.Chunks, info.Digest = 0, 0, _EMPTY_
724
725 if err = publishMeta(info, obs.js); err != nil {
726 return err
727 }
728
729 // Purge chunks for the object.
730 chunkSubj := fmt.Sprintf(objChunksPreTmpl, obs.name, info.NUID)
731 return obs.js.purgeStream(obs.stream, &StreamPurgeRequest{Subject: chunkSubj})
732}
733
734func publishMeta(info *ObjectInfo, js JetStreamContext) error {
735 // marshal the object into json, don't store an actual time

Callers

nothing calls this directly

Calls 4

GetInfoMethod · 0.95
purgeStreamMethod · 0.80
GetObjectInfoShowDeletedFunction · 0.70
publishMetaFunction · 0.70

Tested by

no test coverage detected