Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make working with key-value pairs more convenient #167

Open
cthulhu-rider opened this issue Mar 10, 2022 · 0 comments
Open

Make working with key-value pairs more convenient #167

cthulhu-rider opened this issue Mar 10, 2022 · 0 comments
Labels
enhancement Improving existing functionality I3 Minimal impact S3 Minimally significant U4 Nothing urgent
Milestone

Comments

@cthulhu-rider
Copy link
Contributor

cthulhu-rider commented Mar 10, 2022

Overview

We have several features which are represented as key-value string|binary pairs:

type Attribute object.Attribute

Attribute container.Attribute

type NetworkParameter netmap.NetworkParameter

func (x *prmCommonMeta) WithXHeaders(hs ...string) {

and so on. In order to process them there is a need to use the constant keys. In current implementation they are defined in NeoFS API Go library. I think it is still the best place to define them, but we need to either

  1. create aliases in SDK code
  2. use NeoFS API Go directly in application code.

While 1 seems redundant, 2 is not recommended approach at all.

On the other hand, values ​​encode certain data, which leads to the need to know what and how to decode when processing the value.

So we need smth more convenient.

Proposal

Provide per-key function pair which

  • allows to not use particular key constants
  • encapsulates data encoding
  • abstracts application from the way how data is encoded in some component (e.g. attribute carriers like object or container)
  • saves application from adapting to possible alternative embedding ways (for example, an attribute becomes a field)

A prime example of this approach is a function pair:

func SetNativeNameWithZone(c *Container, name, zone string) {

func GetNativeNameWithZone(c *Container) (name string, zone string) {

These functions allow the application to understand that the container's name and zone can be written to the container descriptor, and abstract away the rest of the details. At the same time, this is not a method of the Container type, which means that the application understands that the function is just an auxiliary one, which means that SDK has all the tools to do the same directly.

I propose to implement function pairs for all such cases. Also it'd be useful to mention these functions in docs of the base methods (SetAttributes for example above).

@cthulhu-rider cthulhu-rider added enhancement Improving existing functionality refactor labels Mar 10, 2022
@roman-khimov roman-khimov added this to the v1.1.0 milestone Feb 1, 2023
@roman-khimov roman-khimov added I4 No visible changes U4 Nothing urgent S3 Minimally significant I3 Minimal impact and removed triage I4 No visible changes labels Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving existing functionality I3 Minimal impact S3 Minimally significant U4 Nothing urgent
Projects
None yet
Development

No branches or pull requests

2 participants