Add object.ExpirationEpoch() method #103

Open
opened 2025-12-28 18:07:00 +00:00 by sami · 3 comments
Owner

Originally created by @carpawell on GitHub (May 27, 2022).

Now we use attrs and constants in CLI and some other places. I think version-independent setter and getter could be helpful.

Think also could be applied to the version-depended repo.

Originally created by @carpawell on GitHub (May 27, 2022). Now we [use](https://github.com/nspcc-dev/neofs-node/blob/dda56f13191c23e2d69b29d98c53c9bd5845ad11/cmd/neofs-cli/modules/object.go#L445) attrs and constants in CLI and some other places. I think version-independent setter and getter could be helpful. Think also could be applied to the version-depended repo.
Author
Owner

@cthulhu-rider commented on GitHub (Aug 30, 2023):

var obj object.Object
obj.SetExpirationEpoch(123)

// is much better to me than

obj.SetAttribute(object.AttrExpirationEpoch, strconv.FormatUint(123, 10))

duplicated call may be resolved differently (panic or leave on the user conscience) and almost definitely unexpected

dedicated method also takes care about format and prevents calls like

obj.SetAttribute(object.AttrExpirationEpoch, "1.5")
@cthulhu-rider commented on GitHub (Aug 30, 2023): ```go var obj object.Object obj.SetExpirationEpoch(123) // is much better to me than obj.SetAttribute(object.AttrExpirationEpoch, strconv.FormatUint(123, 10)) ``` duplicated call may be resolved differently (panic or leave on the user conscience) and almost definitely unexpected dedicated method also takes care about format and prevents calls like ```go obj.SetAttribute(object.AttrExpirationEpoch, "1.5") ```
Author
Owner

@roman-khimov commented on GitHub (Aug 30, 2023):

My concerns are mostly around compatibility (there is old code doing SetAttribute(s)) and API consistency (interaction between this and SetAttribute(s)). If it can be explained in some meaningful way to the user. But this would also mean that a similar API is expected of other system attributes.

@smallhive?

@roman-khimov commented on GitHub (Aug 30, 2023): My concerns are mostly around compatibility (there is old code doing `SetAttribute(s)`) and API consistency (interaction between this and `SetAttribute(s)`). If it can be explained in some meaningful way to the user. But this would also mean that a similar API is expected of other system attributes. @smallhive?
Author
Owner

@smallhive commented on GitHub (Aug 31, 2023):

I consider using separate methods for system/predefined attributes to be more good, than evil. It will help cover some situations, like obj.SetAttribute(object.AttrExpirationEpoch, "1.5"), because we may define an expected type of value. Such moments are important for us rather than for the user. We want to have properly filled and named system attributes.

How many system attributes do we have? Ten, maybe up to twenty, if I remember correctly. Adding new methods will improve object API. Old code is going to work as is, all of them are still available to set via obj.SetAttribute method.

According to the documentation - we should update SetAttribute docs and attract attention to the fact this method is more about user-defined attributes. The method also allows putting system attributes as well, but the preferable way is using separate methods and we should leave the method list

@smallhive commented on GitHub (Aug 31, 2023): I consider using separate methods for system/predefined attributes to be more good, than evil. It will help cover some situations, like `obj.SetAttribute(object.AttrExpirationEpoch, "1.5")`, because we may define an expected type of value. Such moments are important for us rather than for the user. We want to have properly filled and named system attributes. How many system attributes do we have? Ten, maybe up to twenty, if I remember correctly. Adding new methods will improve object API. Old code is going to work as is, all of them are still available to set via `obj.SetAttribute` method. According to the documentation - we should update `SetAttribute` docs and attract attention to the fact this method is more about user-defined attributes. The method also allows putting system attributes as well, but the preferable way is using separate methods and we should leave the method list
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-sdk-go#103
No description provided.