专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

resgateio/resgate Docker 镜像 - 轩辕镜像

resgate
resgateio/resgate
resgateio
A Realtime API Gateway for building REST, and real time APIs, with seamless client synchronization.
1 收藏0 次下载
📦 一套镜像服务,解决研发 / 测试 / 生产三套环境
镜像简介版本下载
📦 一套镜像服务,解决研发 / 测试 / 生产三套环境

Realtime API Gateway
Synchronize Your Clients

Visit Resgate.io for guides, live demos, and resources.


Resgate is a Go project implementing a realtime API gateway for the RES protocol with NATS server as messaging system.

It is a simple server that lets you create REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

Used for building new REST APIs with real-time functionality, or when creating single page applications using reactive frameworks such as React, Vue.js, or Modapp.

!Book Collection Animation
Screen capture from the Book Collection Example. Try out the Live demo version yourself.

How it works

Resgate handles all API requests from your clients, instead of directly exposing your micro-services (represented by Node.js and Java below). Clients will connect to Resgate, using either HTTP or WebSocket, to make requests. These requests are sent to the micro-services over NATS server, and Resgate will keep track on which resource each client has requested.

Whenever there is a change to the data, the responsible micro-service sends an event. Resgate will use this event to both update its own cache, and make sure each subscribing client is kept up-to-date.

Quickstart

If you install Docker, it is easy to run both NATS server and Resgate as containers:

text
docker network create res
docker run -d --name nats -p 4222:4222 --net res nats
docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222

Both images are small, about 10 MB each.

See Resgate.io - Installation for other ways of installation.

Examples

While Resgate may be used with any language, the examples in this repository are written in Javascript for Node.js, without using any additional library.

  • For Go (golang) examples, see go-res package
  • For C# (NETCore) examples, see RES Service for .NET
ExampleDescription
Hello WorldSimple service serving a static message.
Edit TextText field that can be edited by multiple clients concurrently.
Book CollectionList of book titles & authors that can be edited by many.
JWT AuthenticationShowing how JWT tokens can be used for authentication.
Password AuthenticationShowing authentication with user and password credentials.
Client SessionCreating client sessions that survive reloads and reconnects.

Note

All examples are complete with both service and client.

Protocol Specification

For more in depth information on the protocol:

  • RES protocol - Introduction and general terminology
  • RES-Service protocol - How to write services
  • RES-Client protocol - How to write client libraries, if ResClient doesn't fit your needs

Usage

resgate [options]
Server options
OptionDescriptionDefault value
-n, --nats <url>NATS Server URLnats://127.0.0.1:4222
-i, --addr <host>Bind to HOST address0.0.0.0
-p, --port <port>HTTP port for client connections8080
-w, --wspath <path>WebSocket path for clients/
-a, --apipath <path>Web resource path for clients/api/
-r, --reqtimeout <seconds>Timeout duration for NATS requests3000
-u, --headauth <method>Resource method for header authentication
-t, --wsheadauth <method>Resource method for WebSocket header authentication
-m, --metricsport <port>HTTP port for OpenMetrics connections0 (disabled)
    --apiencoding <type>Encoding for web resources: json, jsonflatjson
    --putmethod <methodName>Call method name mapped to HTTP PUT requests
    --deletemethod <methodName>Call method name mapped to HTTP DELETE requests
    --patchmethod <methodName>Call method name mapped to HTTP PATCH requests
    --wscompressionEnable WebSocket per message compression
    --resetthrottle <limit>Limit on parallel requests sent on a system reset0 (no limit)
    --referencethrottle <limit>Limit on parallel requests sent following references0 (no limit)
-c, --config <file>Configuration file in JSON format
Security options
OptionDescriptionDefault value
    --tlsEnable TLS for HTTPfalse
    --tlscert <file>HTTP server certificate file
    --tlskey <file>Private key for HTTP server certificate
    --creds <file>NATS User Credentials file
    --natscert <file>NATS Client certificate file
    --natskey <file>NATS Client certificate key file
    --natsrootca <file>NATS Root CA file(s)
    --alloworigin <origin>Allowed origin(s): *, or <scheme>://<hostname>[:<port>]*
Logging options
OptionDescription
-D, --debugEnable debugging output
-V, --traceEnable trace logging
-DVDebug and trace
Common options
OptionDescription
-h, --helpShow usage message
-v, --versionShow version

Configuration

Configuration is a JSON encoded file. If no config file is found at the given path, a new file will be created with default values as follows.

Properties
javascript
{
    // URL to the NATS server.
    "natsUrl": "nats://127.0.0.1:4222",

    // Bind to HOST IPv4 or IPv6 address.
    // Empty string ("") means all IPv4 and IPv6 addresses.
    // Invalid or missing IP address defaults to 0.0.0.0.
    "addr": "0.0.0.0",

    // Port for the http server to listen on.
    // If the port value is missing or 0, standard http(s) port is used.
    "port": 8080,

    // Metrics port for the OpenMetrics http server to listen on.
    // If the port value is missing or 0, metrics are disabled.
    // Must be different from the configured api port.
    // Metrics are available at the path: /metrics
    "metricsPort": 0,

    // Path for accessing the RES API WebSocket.
    "wsPath": "/",

    // Path prefix for accessing web resources.
    "apiPath": "/api",

    // Timeout in milliseconds for NATS requests.
    "requestTimeout": 3000,

    // Size of message buffer for incoming NATS requests.
    "bufferSize": 8192,

    // Header authentication resource method for web resources.
    // Prior to accessing the resource, this resource method will be called,
    // allowing a service to set a token using information such as the request
    // headers.
    // Missing value or null will disable header authentication.
    // Eg. "authService.headerLogin"
    "headerAuth": null,

    // Header authentication resource method for WebSocket connections.
    // Prior to responding to a WebSocket connection, this resource method will
    // be called, allowing a service to set a token using information such as
    // the request headers.
    // Missing value or null will disable WebSocket header authentication.
    // Eg. "authService.headerLogin"
    "wsHeaderAuth": null,

    // Encoding for web resources.
    // Available encodings are:
    // * json - JSON encoding with resource reference meta data.
    // * jsonflat - JSON encoding without resource reference meta data.
    "apiEncoding": "json",

    // Call method name to map HTTP PUT method requests to.
    // Eg. "put"
    "putMethod": null,

    // Call method name to map HTTP DELETE method requests to.
    // Eg. "delete"
    "deleteMethod": null,

    // Call method name to map HTTP PATCH method requests to.
    // Eg. "patch"
    "patchMethod": null,

    // Flag enabling WebSocket per message compression (RFC 7692).
    "wsCompression": false,

    // Throttle on how many requests are sent in response to a system reset.
    // Once that the number of requests are sent, the server will await
    // responses before sending more requests. Zero (0) means no throttling.
    // Eg. 32
    "resetThrottle": 0,

    // Throttle on how many requests are sent when recursively following
    // resource references for a subscription.
    // Once that the number of requests are sent, the server will await
    // responses before sending more requests. Zero (0) means no throttling.
    // Eg. 32
    "referenceThrottle": 0,

    // Flag enabling tls encryption.
    "tls": false,

    // Certificate file path for tls encryption.
    "tlsCert": "",

    // Key file path for tls encryption.
    "tlsKey": "",

    // NATS User Credentials file.
    // Eg. "ngs.creds"
    "natsCreds": "",

    // NATS Client certificate file.
    // Eg. "client-cert.pem"
    "natsCert": "",

    // NATS Client certificate key file.
    // Eg. "client-key.pem"
    "natsKey": "",

    // NATS Root CA files.
    // Eg. ["rootCA.pem"]
    "natsRootCAs": [],

    // Allowed origin for CORS requests, or * to allow all origins.
    // Multiple origins are separated by semicolon.
    // Eg. "[***]"
    "allowOrigin": "*",

    // Flag enabling debug logging.
    "debug": false,

    // Flag enabling trace logging.
    "trace": false
}

Running Resgate

By design, Resgate will exit if it fails to connect to the NATS server, or if it loses the connection. This is to allow clients to try to reconnect to another Resgate instance and resume from there, and to give Resgate a fresh new start if something went wrong.

A simple bash script can keep it running:

bash
#!/bin/bash
until ./resgate; do
    echo "Resgate exited with code $?.  Restarting.." >&2
    sleep 2
done

Documentation

Visit Resgate.io for documentation and resources.

It has guides on installation, configuration, writing services, scaling, queries, and other useful things. It also contains guides for ResClient when working with frameworks such as React, Vue.js, and Modapp.

Support Resgate

Resgate is an MIT-licensed open source project where development is made possible through community support.

If you'd like help out, please ***:

  • Make a one-time *** via ***
  • Become a backer via GitHub ***

Contribution

Any feedback on the protocol and its implementation is highly appreciated!

If you find any issues with the protocol or the gateway, feel free to report them.

If you have created a service library, a client library, or some other tool or utility, please contact me to have it added to the list of resources.

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

登录仓库拉取

通过 Docker 登录认证访问私有仓库

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

Docker Compose

Docker Compose 项目配置

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

MacOS OrbStack

MacOS OrbStack 容器配置

宝塔面板

在宝塔面板一键配置镜像

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

极空间

极空间 NAS 系统配置服务

爱快路由

爱快 iKuai 路由系统配置

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

专属域名拉取

无需登录使用专属域名

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

轩辕镜像免费版与专业版有什么区别?

免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。

轩辕镜像支持哪些镜像仓库?

专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。

流量耗尽错误提示

当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。

410 错误问题

通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。

manifest unknown 错误

先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。

镜像拉取成功后,如何去掉轩辕镜像域名前缀?

使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
resgateio/resgate
官方博客Docker 镜像使用技巧与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
咨询镜像拉取问题请 提交工单,官方技术交流群:1072982923
轩辕镜像面向开发者与科研用户,提供开源镜像的搜索和访问支持。所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
咨询镜像拉取问题请提交工单,官方技术交流群:
轩辕镜像面向开发者与科研用户,提供开源镜像的搜索和访问支持。所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
官方邮箱:点击复制邮箱
©2024-2026 源码跳动
官方邮箱:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.