Skip to content

[To Dicuss] Plan to increase usability of peernet #100

@Akilan1999

Description

@Akilan1999

Discussion

The following issue is based on the development decision required for the abstraction issue (#99). When implementing the abstraction APIs most of the function and struct as referenced to the webapi package. In my opinion the future work related Peernet should use the abstraction package instead of the webapi package.

Webapi

The Webapi package should only be in-charge of accepting results and calling the abstracted functions and responding with the according results. Most of the Webapi helper functions should be migrated to the abstracted library. This will remove all possible import cycle compilation errors and reduce the size of the Webapi package and generalize all helper function required.

// Sample pseudo code for the Web API with abstractions used. 
func (w *Webapi)<function name>(r *request, w *writer) {
    reqObj := parseRequest(r) 
    resp := abstraction.<function name>(w.backend, <nil/"" (This is only used for direct interaction for preset defaults),reqObj)
    return render.resp 
}

// Example implementation
func (w *Webapi)Search(r *request, w *writer) {
    reqObj := parseRequest(r) 
    resp := abstraction.Search(w.backend, "",reqObj)
    return render.resp 
}

Abstractions

The abstraction library will be designed to take direct input as a parameter or optional parameters (if they are structs or more fine
tuned requirements as requested from the Webapi). The following is an pseudo code example below:

// Example of pseudo code implementation 
func <function name>(b *core.backend,<single native supported datatype>, ...<reqobj>) <struct object pointer>{
      <abstraction implementation> 
       return <struct object pointer>
}

Possible steps to be taken:

  • Implement base abstraction calls and ensure that they point to the Webapi calls. Make sure the Webapi calls are public if needed.
  • Implement all required abstraction API calls.
  • Once all required abstractions are implemented ensure that the helper functions are migrated to the abstraction library.
  • Make sure Webapi only calls abstraction package and not the other way around to ensure there is no import cycle compile time errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions