Git Product home page Git Product logo

downperiscope's Introduction

Down Periscope

Super Duper File Downloader!

Components

  • DownPeriscopeLib: Primary functional library for downloading a file
  • DownPeriscopeTests: Unit tests written against DownPeriscopeLib
  • DownPeriscopeCLI: Command line executable wrapping DownPeriscopeLib
  • DownPeriscopeApp: Preliminary start of a SwiftUI MacOS GUI for DownPeriscopeLib
  • DownPeriscopeUITests: Empty project for writing tests against DownPeriscopeApp

How to build

  • From the command line:
  • Run ./build (always verify scripts before running)
  • The CLI executable will be output to ```pwd``/bin, which will be appended to $PATH`
  • Run ./bin/down --help to see documentation

How to test

  • Open in Xcode (xed .)
  • Run tests with the DownPeriscopeTests scheme

Trade-offs made

  • Started out using Alamofire, as I was most familiar with that library for networking. Half way through realized the Progress object updated and returned by Alamofire is incomplete. It does not contain information that may be provided by the underlying NSURLSession; throughput, estimatedTimeRemaining.
  • Resource URLs need to support HEAD requests, for validating URLs and getting file size. It seemed like the best idea, until I tried a URL that didn't support HEAD requests. So we can put that under improvements

Library Dependencies

  • Alamofire: Chosen for familiarity of using it for networking in Swift
  • RxSwift (includes RxRelay): Prefer reactive programming to imperative. Not yet proficient in Combine
  • swift-log: Standard logging library for Swift code

CLI Dependencies

  • Swift Argument Parser: Standard library for writing CLI applications in Swift

Test Dependencies

  • Nimble: Fantastic library for writing cleaner testing code

Struggles

  • Xcode build output. How do I specify the location of the executable created by DownPeriscopeCLI
    • Expected the DSTROOT set in Xcode to do what it says it does.
    • Instead required using xcodebuild and passing a value as command input:
    • xcodebuild install -scheme DownPeriscopeCLI -configuration Release DSTROOT=/
  • Observable.asSingle()
    • Doesn't complete until the source observable completes.
    • So without something like take(1), or observer.onCompleted() it just waits... ๐Ÿคฆ
  • RxSwift may have been a bad choice. Given the environment of a CLI as a single threaded process, the reactive nature of RxSwift presents a problem. RxSwift is optimal in a multi-threaded environment with a run loop to prevent blocking
    • This particular issue

Improvements

  • Support resources URLs that don't respond to HEAD requests
  • Have Periscope and DefaultRepository better handle their DispatchQueues
  • Add blocking functions to Periscope that abstract away the RxSwift for ease of use from the command line
  • Show throughput as a human readable string (currently B/s)

Distractions (for more fun)

downperiscope's People

Contributors

mgray88 avatar

Watchers

 avatar

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.