Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A dedicated service for storing and managing recorded and replayed data in AREX.

NotificationsYou must be signed in to change notification settings

arextest/arex-storage

Repository files navigation

Arex Icon AREX Storage Service

Introduction

Overview

This HTTP web API manages and accesses recording and replaying resources from a remote repository. Resources are organized as MockItem instances, each corresponding to a MockCategoryType enum.

Key Functions

  1. Agent Recording
    • Assigns version numbers to configuration files.
    • Saves entry points and dependent instances implementing MockItem.
  2. Agent Replaying
    • Reads configuration files by version number prior to replaying.
    • Handles requests, performs diffs, and retrieves mock results as responses.
  3. Scheduled Replaying
    • Uses MainEntry (extending MockItem) as replay trigger sources.
    • Provides diff response sources saved from agent’s replay.

Persistence and Caching

  • Recording Storage (MongoDB): Default persistence for AREX’s agent recording. Collections are time-managed with TTL index expiration.
  • Replaying Cache (Redis): Default cache for AREX’s replaying.

MockItem Interface

The base interface MockItem, defined in arex.storage.model.mocker, is structured as follows:

publicinterfaceMockItem {StringgetReplayId();voidsetReplayId(StringreplayId);StringgetRecordId();voidsetRecordId(StringrecordId);/**       * millis from utc format without timezone       */voidsetCreateTime(longcreateTime);  }

Additional Details

  • Identifiers:replayId andrecordId are generated byAREX's Agent.

  • MainEntry Interface: Defined inarex.storage.model.mocker,MainEntry extendsMockItem and includes methods for accessing request details, category type, format, and more.

    publicinterfaceMainEntryextendsMockItem {/**       * @return utc format without timezone       */longgetCreateTime();/**        * The request's content encoded by base64        *        */StringgetRequest();/**       * @return the mock category type value from MockCategoryType       * @see MockCategoryType       */@JsonIgnoreintgetCategoryType();/**       * How to serialize the request's body to target ,default using application/json       *       * @return application/json or others       */defaultStringgetFormat() {returnnull;      }/**       * @return default http post       */defaultStringgetMethod() {return"POST";      }defaultMap<String,String>getRequestHeaders() {returnnull;      }defaultStringgetPath() {returnnull;      }  }

Getting Started

  1. Configuring Remote Storage:Modify thelocalhost default value inresources/META-INF/application.properties for Redis and MongoDB connections. Example:

    arex.storage.cache.redis.host=redis://10.3.2.42:6379/arex.mongo.uri=mongodb://arex:iLoveArex@10.3.2.42:27017/arex_storage_db
  2. Extending Providers:Implement your own providers using Java'sSPI mechanism. TheCacheProvider interface is defined as:

    publicinterfaceCacheProvider {/**     * 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     */booleanput(byte[]key,longexpiredSeconds,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     */longincrValue(byte[]key);/**     * Decrement the integer value of a key by one.     *     * @param key the key     * @return the value of key after decrement     */longdecrValue(byte[]key);/**     * Delete value specified by the key     *     * @param key the bytes of key     * @return True if key is removed.     */booleanremove(byte[]key);    }

License


[8]ページ先頭

©2009-2025 Movatter.jp