Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
요청 상태를 기반으로 API 요청에 활용되는 커넥터입니다. 접근 제어 및 stateless 커넥터를 연계 할 수 있습니다.
커넥터
어댑터에 위임
연결 가능한 커넥터
개요
call
O
params
, map
분산 서비스 액션을 호출합니다.
publish
O
params
중앙 메시징 서비스에 이벤트를 발행합니다.
subscribe
O
map
중앙 메시징 서비스에서 이벤트를 구독합니다.
GraphQL의 Subscription
타입이나 WebSocket 프로토콜 등을 사용하지 않거나, 분산 시스템에 중앙 메시징 서비스를 제공 할 수 없는 경우엔 publish
, subscribe
커넥터를 구현하지 않아도 무관합니다.
요청 상태가 없는 커넥터입니다.
커넥터
어댑터에 위임
개요
map
X
Inline JavaScript Function String을 VM에서 해석하여 주어진 객체나 응답 객체를 변환합니다.
params
X
요청 페이로드에서 위의 타 커넥터들로 전달 할 객체를 생성합니다.
discover
O
분산 서비스의 업데이트나 종료를 감지하고, 노드, 서비스 API Schema, 액션 및 이벤트 구독, 발행 정보를 수집합니다.
health
O
분산 서비스 및 액션, 중앙 메시징 서비스의 상태 확인을 제공합니다.
reporter
O
출처 노드로 디버그 메세지를 전달합니다.
logger
O
Gateway의 로깅 인스턴스를 제공합니다.
접근 제어 플러그인별 스키마 양식은 섹션을 참조하십시오. 이 섹션에서는 기본 플러그인의 구동 방식을 개괄적으로 설명합니다.
프로토콜의 확장성과 접근제어 정책의 정합성을 위해서, 접근 제어 정책은 프로토콜별 엔드포인트가 아니라 액션과 이벤트를 주체로 적용됩니다.
접근 제어 정책의 평가는 API Gateway의 메모리에 LRU 방식으로 캐시되며 한 요청에서 중복 수행되지 않습니다. 캐시 키를 생성 할 때 요청을 정확히 구분하기 위해서 컨텍스트(인증 정보) 및 호출 페이로드 등의 정보가 반영됩니다.
적용되는 플러그인의 순서는 유효합니다. 우선하는 플러그인에서 실패 할 경우 다음 플러그인의 정책은 평가되지 않습니다. 접근 제어 플러그인의 기본 옵션에서 OAuth2 Scope 플러그인(scopes
)이 FBAC 플러그인(filter
)보다 우선합니다.
OAuth2 Scope 플러그인은 각 정책의 scopes
에 나열된 스코프를 context.scopes
가 하나 이상의 스코프를 포함하는 경우 접근을 허용합니다.
FBAC 플러그인은 각 정책의 filter
항목에 맵핑된 Inline JavaScript Function String을 VM에서 실행하고 그 Boolean
값으로 접근 제어 여부를 판단합니다. 평가중 에러가 발생하거나 Boolean
값이 리턴되지 않는 경우, API Gateway에서 출처 노드로 전달되며 접근이 거부됩니다.
디버깅 중에 Inline JavaScript Function String에서 console
객체를 사용해 메세지를 출력하는 경우, 그 메세지는 console
객체에 바인딩된 report
커넥터가 출처 노드로 전달합니다.
http, https, http2 (WIP)
0.2.x Alpha
Middleware
Helmet (disabled by default)
CORS (enabled, including WebSocket)
Serve Static (disabled)
Body Parser (enabled)
Logging (enabled, including WebSocket)
Error Handler (enabled, including WebSocket)
[X] Context Factory
ID (enabled; request id generation)
User Agent (enabled)
Cookie Parser (enabled)
Locale (enabled)
Auth (enabled; Bearer/OAuth, Basic, Digest, AWS, RFC7235)
Schema Registry plugins
WebSocket protocol plugin
Streaming support for GraphQL/REST plugin multipart/form-data request
Streaming support for REST plugin response
Bidirectional streaming support for WebSocket plugin
0.3.x Beta
Integration example with moleculer-iam
(OIDC provider)
Schema Registry plugins
Filter access control policy plugin
Scope access control policy plugin
Cache policy result in request context
Gateway schema presets
Service Catalog endpoints in REST
Empty scheme placeholder in GraphQL
[] Normalized errors
[] 1.0.x First Stable release
API Server additional protocols
HTTPS
[] HTTP2, HTTP2S
[] Integration example with moleculer-file
[] Unit tests coverage over 90%
[] Memory leak test
[] Stress test and performance profiling
[] Update documents and translate to English
API Gateway constructor options.
APIGatewayOptions type is a kind of container for all the subordinate components' options.
type APIGatewayOptions = {
brokers: RecursivePartial<ServiceBrokerOptions>[],
schema: RecursivePartial<SchemaRegistryOptions>,
server: RecursivePartial<APIServerOptions>,
logger: LoggerConstructorOptions,
} & RecursivePartial<APIGatewayOwnOptions>;
name
default
description
brokers
-
Service Broker constructor options. Can configure multiple brokers for a single gateway. Service Broker discovers remote services and works as a delegator for calling remote service procedures and also deals with central event messages.
schema
-
Schema Registry constructor options. Schema Registry handles the integration of remote service API schema and creates API handlers. Can disable or configure detailed options for each API Schema Plugins like GraphQL, REST and WebSocket, etc.
server
-
API Server constructor options. Can configure API Server update policy, server components (HTTP, WebSocket server) and network interface (HTTP, HTTPS) detailed options, middleware options and request context factory options.
logger
-
Global logger options. Currently logger is supported.
Options for the gateway itself rather inner components.
type APIGatewayOwnOptions = {
skipProcessEventRegistration: boolean;
};
name
default
description
skipProcessEventRegistration
false
Set true to not to set default handlers for process interrupt signals like SIGINT.
Service Broker options are consist of common properties and delegator specific properties. The common properties show below.
type ServiceBrokerOptions = {
registry: ServiceRegistryOptions;
batching: BatchingPoolOptions;
function: InlineFunctionOptions;
reporter: ReporterOptions;
log: {
event: boolean;
call: boolean;
},
} & ServiceBrokerDelegatorConstructorOptions;
name
default
description
registry
-
Options for the ServiceRegistry which collect remote services, available procedures and event types, etc.
batching
-
Options for batching feature which utilize for concurrent multiple procedure calls.
function
-
Options for inline function (JS function notation string) sandbox.
reporter
-
Options for remote service reporter instance which reports API integration status, error or logging in inline function sandbox, etc.
log.event
true
Enable logging event messages.
log.call
true
Enable logging remote procedure call.
type ServiceRegistryOptions = {
examples: {
processIntervalSeconds: number;
queueLimit: number;
limitPerActions: number;
limitPerEvents: number;
streamNotation: string;
omittedNotation: string;
omittedLimit: number;
redactedNotation: string;
redactedParamNameRegExps: RegExp[];
};
healthCheck: {
intervalSeconds: number;
};
};
name
default
description
examples
-
Options for the ServiceRegistry action (remote procedure), event example collecting feature.
examples.processIntervalSeconds
5
Consume example queue for every given intervals.
examples.queueLimit
50
Example queue size.
examples.limitPerActions
10
Maximum number of examples for a single action (remote procedure).
examples.limitPerEvents
10
Maximum number of examples for a single event.
examples.streamNotation
*STREAM*
Replace stream request and response of an example to given string.
examples.omittedNotation
*OMITTED*
Truncate example object's string property and append given suffix for...
examples.omittedLimit
100
The strings longer than given length.
examples.redactedNotation
*REDACTED*
React example object's string property to given string for...
examples.redactedParamNameRegExps
[
/password/i,
/secret/i,
/credential/i,
/key/i,
/token/i,
]
Matched strings with given regular expressions.
healthCheck
-
Options for the ServiceRegistry health check feature.
healthCheck.intervalSeconds
10
Health check for every given intervals.
type BatchingPoolOptions = {
batchingKey: (...args: any[]) => any;
entryKey: (batchingParams: any) => any;
failedEntryCheck: (entry: any) => boolean;
entriesLimit: number;
};
name
default
description
batchingKey
(hash function)
A keygen function for the key of same batching arguments. Create hash string with args object by default.
entryKey
(hash function)
A keygen function for the variable params of each batched entries.
failedEntryCheck
entry => entry && entry.batchingError
A function to determine whether each entries are failed or not in a batch response. By default, a remote procedure which supports batching should response { ..., batchingError: true }
object for failed entry.
entriesLimit
100
Maximum number of entries for a single batch.
type InlineFunctionOptions = {
util: {[key: string]: any};
};
name
default
description
util
{}
Any kind of object which can be accessed as global util
variable from inline functions.
type ReporterOptions = {
tableWidthZoomFactor: number;
};
name
default
description
tableWidthZoomFactor
1
A reporter sends a report which is consist of raw messages and a string that prints messages as a shape of a table. For that table, set a zoom factor of the width.
Specific options for the Service Broker Delegator. Can choose only one among supported delegators. Currently moleculer delegator is supported.
type ServiceBrokerDelegatorConstructorOptions = {
moleculer?: MoleculerServiceBrokerDelegatorOptions;
[otherDelegatorKey: string]?: never;
};
name
default
description
moleculer
-
Service Broker Delegator options.
moleculer delegator can be configured with moleculer broker own options and few extra options like below.
import * as Moleculer from "moleculer";
type MoleculerServiceBrokerDelegatorOptions = Moleculer.BrokerOptions & {
batchedCallTimeout: (itemCount: number) => number;
streamingCallTimeout: number;
streamingToStringEncoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
services: Moleculer.ServiceSchema[];
};
name
default
description
batchedCallTimeout
(return 5-60s based on item count)
A function to calculate the timeout options for a batched call.
streamingCallTimeout
3600000 (1 hour)
A timeout options for a streaming call (ms).
streamingToStringEncoding
base64
An encoding which is used to transform streaming data to buffer data. This is for the case that non-root property of payload is a readable stream. Because moleculer service broker can pipe only a single streaming data at once in a single params, a gateway needs to transform non-root streaming data to buffer data before proxy the action call. Try to check your moleculer service broker transporter options and this option for a malformed streaming data issue.
services
[]
Given Moleculer.ServiceSchema[]
would be registered on moleculer service broker started. This is for the testing convenience.
Service Registry options are consist of own options for the registry itself and Protocol, Policy, this two type of Plugin constructor options.
type SchemaRegistryOptions = {
maxVersions: number;
maxUnusedSeconds: number;
protocol: ProtocolPluginConstructorOptions,
policy: PolicyPluginConstructorOptions,
};
name
default
description
maxVersions
10
Maximum number of old versions for each branches.
maxUnusedSeconds
1800
Maximum unused duration until deleting non-master branches.
protocol
-
Options for Protocol Plugins.
policy
-
Options for Policy Plugins.
A ProtocolPlugin handles mapping Public API to calling internal services' procedure, publishing and subscribing event messages.
type ProtocolPluginConstructorOptions = {
REST: RecursivePartial<RESTProtocolPluginOptions> | false;
GraphQL: RecursivePartial<GraphQLProtocolPluginOptions> | false;
WebSocket: RecursivePartial<WebSocketProtocolPluginOptions> | false;
}
name
default
description
REST
-
Options for REST Protocol Plugin.
GraphQL
-
Options for Protocol Plugin.
WebSocket
-
Options for Protocol Plugin.
WIP
A PolicyPlugin handles access controls (authorization) while calling internal services' procedure, publishing and subscribing event messages.
type PolicyPluginConstructorOptions = {
scope: RecursivePartial<ScopePolicyPluginOptions> | false;
filter: RecursivePartial<FilterPolicyPluginOptions> | false;
};
name
default
description
scope
-
Options for Scope Policy Plugins.
filter
-
Options for Filter Policy Plugins.