@@ -2,10 +2,10 @@ Data Transfer and Abstraction
2
2
=============================
3
3
Abstracted APIs should attempt to hide the implementation details of
4
4
the remote or local API in a well organized data model. This data
5
- model should avoid returning raw JSON, gRPC messages, SWIG objects, or
6
- .NET objects. Rather, it preferable to return standard Python objects
7
- like lists, strings, dictionaries when useful, and NumPy arrays or
8
- pandas dataframes for more complex data.
5
+ model should avoid returning raw JSON files , gRPC messages, SWIG objects,
6
+ or .NET objects. It should preferably return standard Python objects
7
+ like lists, strings, dictionaries when useful, and ` NumPy < https://numpy.org/ >`_
8
+ arrays or ` pandas < https://pandas.pydata.org/ >`_ dataframes for more complex data.
9
9
10
10
For example, consider a simple mesh in MAPDL:
11
11
@@ -16,9 +16,9 @@ For example, consider a simple mesh in MAPDL:
16
16
>> > mapdl.et(1 , 186 )
17
17
>> > mapdl.vmesh(' ALL' )
18
18
19
- At this point, the only two ways within MAPDL to access the nodes and
20
- connectivity of the mesh are either to print it using the ``NLIST ``
21
- command or to write it to disk using the ``CDWRITE `` command. Both
19
+ At this point, there are only two ways within MAPDL to access the nodes and
20
+ connectivity of the mesh, You can either print it using the ``NLIST ``
21
+ command or write it to disk using the ``CDWRITE `` command. Both of these
22
22
methods are remarkably inefficient, requiring:
23
23
24
24
- Serializing the data to ASCII on the server
@@ -65,28 +65,28 @@ within the MAPDL database.
65
65
[0.75 , 0.5 , 0.5 ]])
66
66
67
67
68
- REST vs RPC Data and Model Abstraction
69
- --------------------------------------
70
- Because of the nature of Ansys's products, our applications and
71
- services can either fit into the RPC interface where the API is
72
- centered around operations and commands, or the REST model which is
73
- centered around resources. Regardless of the the interface style,
74
- there are several items to consider.
68
+ REST Versus RPC Data and Model Abstraction
69
+ ------------------------------------------
70
+ Because of the nature of most Ansys products, our applications and
71
+ services can either fit into the RPC interface, where the API is
72
+ centered around operations and commands, or the REST model, where
73
+ the API is centered around resources. Regardless of the the interface
74
+ style, there are several items to consider.
75
75
76
76
77
77
API Chattiness
78
78
~~~~~~~~~~~~~~
79
- APIs must be efficient to avoid creating chatty I/O. Because many of
80
- Ansys's products fit well with the RPC API implementation, there is a
81
- temptation to design APIs that require constant communication with the
82
- remote or local service. However, just because RPC interfaces can,
83
- does not mean they should as it should be assumed that each RPC call
84
- takes significant time to execute.
85
-
86
- One way to avoid this approach is to either serialize several
87
- "commands" for services that employ an internal "command pattern" for
88
- data exchange. Another approach is to encapsulate the data model
89
- entirely on the server and avoid data transfer whenever possible and
79
+ APIs must be efficient to avoid creating chatty input and output.
80
+ Because many Ansys products fit well with the RPC API implementation,
81
+ there is a temptation to design APIs that require constant communication
82
+ with the remote or local service. However, just because RPC interfaces
83
+ can do this, it does not mean that they should. The assumption should be
84
+ that each RPC call takes significant time to execute.
85
+
86
+ One way to avoid constant communication with the service is to serialize
87
+ several "commands" for services that employ an internal "command pattern"
88
+ for data exchange. Another approach is to encapsulate the data model
89
+ entirely on the server to avoid data transfer whenever possible and
90
90
expose only a limited number of RPC methods in the front-facing API.
91
91
92
92
Compatibility and Efficiency
@@ -97,16 +97,15 @@ of the first choices due to its compatibility with nearly all popular
97
97
languages and its efficiency over REST in terms of speed, memory, and
98
98
payload size.
99
99
100
- Typically, data exchange over REST should be limited to short messages
101
- exchanged over JSON, whereas gRPC can handle large data transfer and
102
- even allows for bidirectional streaming.
103
-
104
- In general, it is preferable to choose gRPC over REST due to the
105
- performance benefits of a binary compatible protocol. While REST
106
- carries a variety of benefits, for complex client/server interactions,
107
- it is best to have an interface that can efficiently exchange a wide
108
- variety of data formats and messages.
100
+ Typically, REST data exchanges should be limited to short messages
101
+ transferred via JSON files, and gRPC should be used for large data
102
+ transfers and bidirectional streaming.
109
103
104
+ Choosing gRPC over REST is generally preferable due to the performance
105
+ benefits of a binary compatible protocol. While REST provides a variety of
106
+ benefits, for complex client/server interactions, it is best to have an
107
+ interface that can efficiently exchange a wide variety of data formats and
108
+ messages.
110
109
111
110
112
111
.. _gRPC : https://grpc.io/
0 commit comments