Skip to content

Useful extensions#766

Merged
roman-khimov merged 5 commits intomasterfrom
useful-extensions
Jan 16, 2026
Merged

Useful extensions#766
roman-khimov merged 5 commits intomasterfrom
useful-extensions

Conversation

@roman-khimov
Copy link
Copy Markdown
Member

No description provided.

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>
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.68%. Comparing base (923817f) to head (d0b6057).
⚠️ Report is 16 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InitCreation with New(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() and Object.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.

Comment thread object/object.go
Comment thread object/id/address.go
Comment thread object/object.go
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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread container/id/id.go
return true
}

// Compare performs three-way comparison of [ID] and returns the result. It
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread object/object.go
o.SetContainerID(rf.Container)
o.SetOwner(rf.Owner)
}
o.SetVersion(&v)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets assert this in TestNew

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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>
@roman-khimov
Copy link
Copy Markdown
Member Author

I'll wait for #762 and #765 to get in, this will require some adjustments in node.

roman-khimov added a commit to nspcc-dev/neofs-node that referenced this pull request Jan 12, 2026
Adapt for nspcc-dev/neofs-sdk-go#766.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
roman-khimov added a commit to nspcc-dev/neofs-node that referenced this pull request Jan 12, 2026
Adapt for nspcc-dev/neofs-sdk-go#766.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
@roman-khimov
Copy link
Copy Markdown
Member Author

#762 is pretty much independent and gate-only thing, merging this.

@roman-khimov roman-khimov merged commit 3b7fe1f into master Jan 16, 2026
9 of 10 checks passed
@roman-khimov roman-khimov deleted the useful-extensions branch January 16, 2026 07:46
roman-khimov added a commit to nspcc-dev/neofs-node that referenced this pull request Jan 16, 2026
Adapt for nspcc-dev/neofs-sdk-go#766.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
roman-khimov added a commit to nspcc-dev/neofs-node that referenced this pull request Jan 16, 2026
Adapt for nspcc-dev/neofs-sdk-go#766.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
roman-khimov added a commit to nspcc-dev/neofs-rest-gw that referenced this pull request Jan 16, 2026
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>
roman-khimov added a commit to nspcc-dev/neofs-s3-gw that referenced this pull request Jan 16, 2026
Bring nspcc-dev/neofs-sdk-go#765 and
nspcc-dev/neofs-sdk-go#766 in.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants