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

Method GetInfo

object.go:944–977  ·  view source on GitHub ↗

GetInfo will retrieve the current information for the object.

(name string, opts ...GetObjectInfoOpt)

Source from the content-addressed store, hash-verified

942
943// GetInfo will retrieve the current information for the object.
944func (obs *obs) GetInfo(name string, opts ...GetObjectInfoOpt) (*ObjectInfo, error) {
945 // Grab last meta value we have.
946 if name == "" {
947 return nil, ErrNameRequired
948 }
949 var o getObjectInfoOpts
950 for _, opt := range opts {
951 if opt != nil {
952 if err := opt.configureGetInfo(&o); err != nil {
953 return nil, err
954 }
955 }
956 }
957
958 metaSubj := fmt.Sprintf(objMetaPreTmpl, obs.name, encodeName(name)) // used as data in a JS API call
959 stream := fmt.Sprintf(objNameTmpl, obs.name)
960
961 m, err := obs.js.GetLastMsg(stream, metaSubj)
962 if err != nil {
963 if errors.Is(err, ErrMsgNotFound) {
964 err = ErrObjectNotFound
965 }
966 return nil, err
967 }
968 var info ObjectInfo
969 if err := json.Unmarshal(m.Data, &info); err != nil {
970 return nil, ErrBadObjectMeta
971 }
972 if !o.showDeleted && info.Deleted {
973 return nil, ErrObjectNotFound
974 }
975 info.ModTime = m.Time
976 return &info, nil
977}
978
979// UpdateMeta will update the meta for the object.
980func (obs *obs) UpdateMeta(name string, meta *ObjectMeta) error {

Callers 6

PutMethod · 0.95
GetMethod · 0.95
DeleteMethod · 0.95
AddLinkMethod · 0.95
AddBucketLinkMethod · 0.95
UpdateMetaMethod · 0.95

Calls 4

encodeNameFunction · 0.70
configureGetInfoMethod · 0.65
GetLastMsgMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected