Skip to content

op env's get_by_path return value different from root_state_accessor_stub's get_object_by_path #235

Closed

Description

@weiqiushi

path op env's get_by_path has return value BuckyResult<Option>
it shows when path not exists, it may return Ok(None)

but root_state_accessor_stub's get_object_by_path function has return value BuckyResult

I think when path not exists, it will return BuckyErrorCode::NotFound?

Is there a need to make the return values of these two functions same?

Activity

  1. lurenpluto commented on Apr 22, 2023

    @lurenpluto
    Member

    This should be formed by some historical reasons, in the rpc interface, if the target does not exist, either return None, or NotFound error

    get_object_by_path

    For accessor.get_object_by_path method, this internal is integrated with the root-state and non interfaces, so at the beginning of the design, the counterpart is non.get_object (because the semantics are closer), and non.get_object is a very old interface, at the beginning of the design is designed to return NotFound when the target object does not exist

    get_object_by_path's target does not exist, but also contains two layers of meaning

    • The corresponding path does not exist on the root-state
    • The object_id corresponding to root-state/{path}, but the corresponding object does not exist

    op-env's get relate methods

    op-env is designed to add, delete, check and change global-state (root-state + local-cache), so if the path does not exist, it is more friendly to return None directly, against the interface of some common data structures, such as the get interface of rust's HashMap

    https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.get

  2. locked and limited conversation to collaborators on Apr 23, 2023
  3. converted this issue into a discussion #240 on Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Any IdeaAny problem/ideas/suggestionsUser-friendlinessTo improve the usability of the interface & SDKquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions