Useful extensions#766
Conversation
Simplify sorting. Signed-off-by: Roman Khimov <roman@nspcc.ru>
oid.ID and cid.ID have it, Address should have it too. Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
objectcore.AddressOf() in node suggests we need it in SDK. Signed-off-by: Roman Khimov <roman@nspcc.ru>
1fccdd9 to
c8a8488
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #766 +/- ##
==========================================
- Coverage 59.13% 58.68% -0.46%
==========================================
Files 167 167
Lines 19103 19685 +582
==========================================
+ Hits 11297 11552 +255
- Misses 7507 7830 +323
- Partials 299 303 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request introduces useful extensions to the NeoFS SDK by refactoring the object creation API and adding comparison/utility methods for ID types. The main changes simplify object creation by replacing the verbose InitCreation pattern with a more concise New constructor that takes required fields directly.
- Simplified object creation API: replaced
InitCreationwithNew(containerID, ownerID)that returns a pointer - Added comparison methods (
Compare) for container IDs, object IDs, and addresses to enable sorting - Added utility methods:
Address.IsZero()andObject.Address()
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| object/object.go | Refactored New() to accept mandatory fields and return pointer; removed RequiredFields and InitCreation; added Address() method |
| object/object_test.go | Updated test to use new New() API; added test for Address() method |
| object/object_internal_test.go | Updated internal tests to use new New() API and dereference pointers appropriately |
| object/test/generate.go | Updated test helpers to use new New() API with container and owner parameters |
| pool/pool_aio_test.go | Updated test usage to call New() with required parameters and dereference the returned pointer |
| client/example_object_test.go | Updated example to demonstrate new New() API usage |
| object/id/id.go | Added Compare() method for three-way comparison of object IDs |
| object/id/id_test.go | Added tests for new Compare() method |
| object/id/address.go | Added IsZero() and Compare() methods for address types |
| object/id/address_test.go | Added comprehensive tests for new IsZero() and Compare() methods |
| container/id/id.go | Added Compare() method for three-way comparison of container IDs |
| container/id/id_test.go | Added tests for new container ID Compare() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Container cid.ID | ||
| // New creates and initializes new [Object] with the current version from SDK | ||
| // and given mandatory fields. | ||
| func New(cnr cid.ID, owner user.ID) *Object { |
There was a problem hiding this comment.
any version i have seen so far doesn't seem sufficient to me, but i have nothing to suggest either, so let it set the version at least now
| return true | ||
| } | ||
|
|
||
| // Compare performs three-way comparison of [ID] and returns the result. It |
There was a problem hiding this comment.
have been thinking for ~1 min about whether it is an exhaustive description. Likely it is ok, but when i use GO's std libs i always compare with -1, +1, but there it should not be considered as a correct comparison since it is not mentioned
| o.SetContainerID(rf.Container) | ||
| o.SetOwner(rf.Owner) | ||
| } | ||
| o.SetVersion(&v) |
There was a problem hiding this comment.
lets assert this in TestNew
New() is absolutely useless. InitCreation() is needlessly complex. I believe
combining them gives exactly what people wanted in the first place: some way
to create object that works. For decoding new(object.Object) or
&object.Object{} are still valid and convenient, but when assembling something
for Put() to use I'd rather have this new New().
Yes, it's a breaking change, but adapting to it is trivial.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
c8a8488 to
d0b6057
Compare
Adapt for nspcc-dev/neofs-sdk-go#766. Signed-off-by: Roman Khimov <roman@nspcc.ru>
Adapt for nspcc-dev/neofs-sdk-go#766. Signed-off-by: Roman Khimov <roman@nspcc.ru>
|
#762 is pretty much independent and gate-only thing, merging this. |
Adapt for nspcc-dev/neofs-sdk-go#766. Signed-off-by: Roman Khimov <roman@nspcc.ru>
Adapt for nspcc-dev/neofs-sdk-go#766. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This brings pool fix with it (nspcc-dev/neofs-sdk-go#765) as well as API changes (nspcc-dev/neofs-sdk-go#766), but looks like REST isn't using these APIs. Signed-off-by: Roman Khimov <roman@nspcc.ru>
Bring nspcc-dev/neofs-sdk-go#765 and nspcc-dev/neofs-sdk-go#766 in. Signed-off-by: Roman Khimov <roman@nspcc.ru>
No description provided.