Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
“License”); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
“AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
NexresRPC contains three components: Acceptor, Service, and ReplicaClient.
Acceptor runs two types of connections: Long Connection that is built between internal services, and Short Connection that is connected from the user clients.
- Long Connection uses an Async Acceptor, which uses the boost::asio library as the core io operator, to manage the socket channels.
- Short Connection uses the standard tcp socket library to accept a client request. The client socket information will be passed to the service in case they need to send messages back to the client. The incoming messages will be pushed into the message input queue(MIQ).
Service runs multiple workers which keep watching the incoming messages from MIQ, popping and executing. Messages that need to be delivered to other services will be pushed into the message output queue(MOQ).
ReplicaClient is also an asnychronous io client which uses the boost::asio library to send out the messages from MOQ as well. Async Replica Client handlers a few numbers of boost::io_service so as to fully utilize the IO write. Messages from MOQ will be grouped as one batch to reduce the IO latency.