forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionFactory.h
More file actions
49 lines (42 loc) · 1.49 KB
/
ConnectionFactory.h
File metadata and controls
49 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <folly/Function.h>
#include <folly/futures/Future.h>
#include "rsocket/DuplexConnection.h"
namespace folly {
class EventBase;
}
namespace rsocket {
/**
* Common interface for a client to create connections and turn them into
* DuplexConnections.
*
* This is primarily used with RSocket::createClient(ConnectionFactory)
*
* Built-in implementations can be found in rsocket/transports/, such as
* rsocket/transports/TcpConnectionFactory.h
*/
class ConnectionFactory {
public:
ConnectionFactory() = default;
virtual ~ConnectionFactory() = default;
ConnectionFactory(const ConnectionFactory&) = delete; // copy
ConnectionFactory(ConnectionFactory&&) = delete; // move
ConnectionFactory& operator=(const ConnectionFactory&) = delete; // copy
ConnectionFactory& operator=(ConnectionFactory&&) = delete; // move
struct ConnectedDuplexConnection {
std::unique_ptr<rsocket::DuplexConnection> connection;
folly::EventBase& eventBase;
};
/**
* Connect to server defined by constructor of the implementing class.
*
* Every time this is called a new transport connection is made. This does not
* however mean it is a physical connection. An implementation could choose to
* multiplex many RSocket connections on a single transport.
*
* Resource creation depends on the particular implementation.
*/
virtual folly::Future<ConnectedDuplexConnection> connect() = 0;
};
} // namespace rsocket