nspcc-dev / neofs-sdk-go

Go implementation of NeoFS SDK
Apache License 2.0
6 stars 14 forks source link

object: Provide helper methods for system attributes #630

Closed cthulhu-rider closed 1 month ago

cthulhu-rider commented 1 month ago

Is your feature request related to a problem? Please describe.

I'm always frustrated when user needs to do following to set the object expiration:

        attrs := obj.Attributes()
        var expAttrFound bool
        expAttrValue := strconv.FormatUint(exp, 10)

        for i := range attrs {
            if attrs[i].Key() == object.AttributeExpirationEpoch {
                attrs[i].SetValue(expAttrValue)
                expAttrFound = true
                break
            }
        }

        if !expAttrFound {
            index := len(attrs)
            attrs = append(attrs, object.Attribute{})
            attrs[index].SetKey(object.AttributeExpirationEpoch)
            attrs[index].SetValue(expAttrValue)
        }

        obj.SetAttributes(attrs...)

he should care about: expiration is an attribute, it should be unique and formatted correctly

Describe the solution you'd like

add Container.SetCreationTime + Container.CreatedAt analogs

Describe alternatives you've considered

keep tryhard

Additional context

https://github.com/nspcc-dev/neofs-node/pull/2943

carpawell commented 1 month ago

We also have https://github.com/nspcc-dev/neofs-sdk-go/issues/253 with some messages there.

cthulhu-rider commented 1 month ago

oh these issue names...