Code Monkey home page Code Monkey logo

vertx-rest-mirror's Introduction

vertx-mirror

Build Status codecov Maven Central

A verticle that mirrors resources, which are provided as zip into a rest storage

Provide resources as zip

The zip has to be accessible over http, eg. http://host:8888/bla/blo/ble/resources.zip. The zip can contain arbitrary resources (files), the file types are not relevant. The resources (files) can be zipped in any path depth, the path will be mapped to the rest storage.

The API

POST http://localhost:8686/mirror

Payload:

{
    "path": "relative/path/to/the/zip.zip" // Relative path (see config parameter mirrorRootPath) to the zip
    ["content-type": "application/json"]  // optional - content-type of the content elements in zip file
}

Configuration

{
    "serverPort": 8686 // where the http server is listen on, standard is 8686
    "selfClientHost": "localhost" // where the verticle access the zip, standard is localhost
    "selfClientPort": 7012 // where the verticle access the zip, standard is 7012
    "mirrorHost": "localhost" // where the zip file entries are putted, standard is localhost
    "mirrorPort": 7012 // where the zip file entries are putted, standard is 7012
    "mirrorRootPath": "/root" // the root path, that is used to get the zip and to put the resources, standard is "/root"
    "internalRequestHeaders": // Array of arrays holding request headers which are added to all outgoing requests
}

Example:

{
    "serverPort": 8686,
    "selfClientHost": "localhost",
    "selfClientPort": 7012,
    "mirrorHost": "localhost",
    "mirrorPort": 7012,
    "mirrorRootPath": "/root",
    "internalRequestHeaders": [["x-foo", "bar"], ["x-bar", "zzz"]]
}

Dependencies

  • Versions 2.2.x (and later) of Rest-Mirror require Java 11.

  • Versions 2.1.14 (and later) of Rest-Mirror depend on org.swisspush.rest-storage

  • Versions 02.xx.xx (and later) of Rest-Mirror depend on Vert.x v3.2.0, therefore Java 8 is required

vertx-rest-mirror's People

Contributors

swisspusher avatar mcweba avatar floriankammermann avatar dominik-cnx avatar linovifian avatar lbovet avatar ljucam avatar dependabot[bot] avatar stirbsli avatar

Stargazers

 avatar  avatar

Watchers

Andrea Chiodoni avatar Edouard Coissy avatar  avatar James Cloos avatar Xin avatar  avatar Markus Guenther avatar  avatar Oli avatar

vertx-rest-mirror's Issues

Write deltasync only if successful and reset if it is higher than in source

If the mirror fails for one element ...

{
  "success" : false,
  "loadedresources" : [ {
    "path" : "test_mirror/t1.json",
    "success" : true
  }, {
    "path" : "test_mirror/t1/browser.css",
    "success" : false
  }, {
    "path" : "test_mirror/t2/t21/test.html",
    "success" : true
  }, {
    "path" : "test_mirror/t2/t22/t31/loader.gif",
    "success" : true
  }, {
    "path" : "test_mirror/t2/t22/t31/test.png",
    "success" : true
  } ]
}

the deltasync may not be written! The old value must preserve in order to have a chance retrieve the whole delta another time.

If the mirror receives a x-delta which is higher (this may happen if the source server has a storage reset) than on the source host, the mirror has to be performed with x-delta 0 in order to get a proper set of elements and a correct x-delta value.

Provide default request headers for mirror requests

With the change (#350) in gateleen, the RoleAuthorizer can now reject requests sent without any roles.
The vertx-rest-mirror makes internal requests which are blocked when the RoleAuthorizer is configured to reject requests without roles.

To fix this, we have to provide a way to configure the HTTP request headers which have to be added to all internal requests. See #353 Provide default request headers for scheduler requests for an implementation example.

MirrorMod hangs when receiving defective ZIP-Stream

MIrrorMod's ZipFileEntryIterator hides an IOException behind a RuntimeException:
https://github.com/swisspush/vertx-rest-mirror/blob/72e967b70c3261922d826139e30c2026b3cf770a/src/main/java/org/swisspush/mirror/ZipFileEntryIterator.java#L74-L76

In case of defective ZIP-Streams this leads to uncatched Exceptions in a Handler and then to a not-ended HttpServerResponse:

Additionally a further bunch of findings after code review:

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.