Giter Club home page Giter Club logo

arex-storage's Introduction

Arex Icon AREX's Storage Service

Introduction

It is an http web APIs used to manage or access the recording and replaying resources from remote repository, which it structured by MockItem for each category enums:MockCategoryType.

The primary functions as following:

  1. for the agent recording
    • provide a version number for all config files
    • save all the entry point & dependent instances which implemented MockItem
  2. for the agent replaying
    • read the config file by version number before replaying
    • receive the request to diff and read a mock result as response
  3. for the schedule replaying
    • provide entry points as replay trigger source structured by MainEntry extends MockItem
    • provide diff response source which saved from agent's replay

Currently, we use mongodb as default persistence for AREX's agent's recording, because the item of collection will dropped by the TTL index expired.

we use Redis as default cache provider for AREX's replaying.

The MockItem is a base interface defined in the package arex.storage.model.mocker as following:

  public interface MockItem {
      String getReplayId();
  
      void setReplayId(String replayId);
  
      String getRecordId();
  
      void setRecordId(String recordId);
  
      /**
       * millis from utc format without timezone
       */
      void setCreateTime(long createTime);
  }

Note: The value of replayId and recordId from beginning to end created by AREX's Agent.

The MainEntry is a base interface defined in the package arex.storage.model.mocker as following:

  public interface MainEntry extends MockItem {
 
      /**
       * @return utc format without timezone
       */
      long getCreateTime();
      /**
        * The request's content encoded by base64
        *
        */
      String getRequest();
  
      /**
       * @return the mock category type value from MockCategoryType
       * @see MockCategoryType
       */
      @JsonIgnore
      int getCategoryType();
  
      /**
       * How to serialize the request's body to target ,default using application/json
       *
       * @return application/json or others
       */
      default String getFormat() {
          return null;
      }         
  
      /**
       * @return default http post
       */
      default String getMethod() {
          return "POST";
      }
  
      default Map<String, String> getRequestHeaders() {
          return null;
      }
  
      default String getPath() {
          return null;
      }
  }

Getting Started

  1. Modify default value localhost

    If you use default providers as remote storage implementation, you should be change the connection string in the file of path 'resources/META-INF/application.properties'.

    example for Redis & mongodb connection:

    arex.storage.cache.redis.host=redis://10.3.2.42:6379/
    arex.storage.mongo.host=mongodb://arex:[email protected]:27017/arex_storage_db
    
  2. Extends your providers

    We use java's SPI mechanism to support your implementation.

    The storage cache interface arex.common.cache.CacheProvider defined as following:

    public interface CacheProvider {
        /**
         * put the value with expired seconds
         * @param key the key for value
         * @param expiredSeconds  the expired seconds
         * @param value bytes of the object
         * @return true if success,others false
         */
        boolean put(byte[] key, long expiredSeconds, byte[] value);    
            
        /**
         * Get the value of a key
         *
         * @param key the bytes of key
         * @return null when key does not exist.
         */
        byte[] get(byte[] key);
    
        /**
         * Increment integer value of the key by on
         *
         * @param key the key
         * @return The value of the key after increment
         */
        long incrValue(byte[] key);
    
        /**
         * Decrement the integer value of a key by one.
         *
         * @param key the key
         * @return the value of key after decrement
         */
        long decrValue(byte[] key);
    
        /**
         * Delete value specified by the key
         *
         * @param key the bytes of key
         * @return True if key is removed.
         */
        boolean remove(byte[] key);    
    }

License

arex-storage's People

Contributors

binyu1005 avatar coryhh avatar mokdeve avatar pangdayuan1 avatar wildeslam avatar sljoyy avatar mentosl avatar qizhengmo avatar yongwuhe avatar mr3 avatar wangyechao 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.