Code Monkey home page Code Monkey logo

networkit's Introduction

๐Ÿ›œ Networkit

Network Kit? Network It? Net workit?

Declarative Networking for Swift

Description

Networkit aims to provide easy to use yet powerful networking features. The library works with a basic "Requestable" concept; any class or struct can be made requestable and then requested.

Key Features

  • Observable requests
  • Callback and Async/Await support
  • Response caching
  • Automatic identical request merging
  • Easy custom queue declaring
  • Extendable with custom tasks

Installation

Swift Package Manager

Swift package manager is the preferred way to use Networkit. Just add this repository. Locking to the current minor version is recommended.

https://github.com/BergerBytes/swift-networking

Simple Example

struct PingEndpoint: Decodable {
    let someData: String
}

extension PingEndpoint: Endpoint {
    static var method: RequestMethod = .get
    static func path(given _: NoParameters) -> URLPath? {
        "endpoint" / "path" / "to" / "ping"
    }
}
let response = try await PingEndpoint.request()

networkit's People

Contributors

bergerbytes avatar

Stargazers

Pete avatar  avatar

Watchers

 avatar

networkit's Issues

WIP: Custom Request Queues

Add optional custom request queue assignment to Requestables. Custom queues will be an optional implementation allowing the host application to define custom request queues.

Use case

Low priority, background requests could be directed to a specified queue to avoid "clogging" the request pipeline for more critical requests. For example, having all authentication/token refresh requests run on a dedicated queue would prevent them from fighting against other priority requests.

Goals

  • Queues should allow for custom configurations, for example, the label and the maximum number of requests.
  • The queue definition should be static as part of the Requestable protocol. The library would create and manage the queues as needed.
  • Jumping queues would be useful given the library merges requests and currently raises/lowers request priority based on observers. However, this could be challenging if queues are defined statically on requests. The queue definition might need to allow for a more conditional definition. An initial thought could be a structure defining multiple queues with jump rules. Ideally, this would all be optional and thus only introduce complexity for those who need it.

WIP: Request Retrying

Add a Retryable protocol to go along with Requestable and Cacheable that defines requests that should be retried on failure. The protocol should allow for defining the retry policy.

Better Name

This networking package is called "DeclarativeNetworking"; that just won't do!

Sorted Query Parameters

The order in which query params are appended to the url would ideally be sorted deterministically by name.

Add ability to expire, but not delete, cache data in the NetworkManager

Add the ability to expire cached data without deleting it. Applications can use this to set an endpoint data as expired when an action was taken that you know, or expect, will invalidate or update the data, but you don't need to fetch the updates immediately.

Right now, the cache layer is leveraging Cache; it's unknown if this is a supported feature of the package. One of the longer-term goals is to move to a custom caching system for more control. Ideally, that will not be needed for this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.