public async Task InstantSideloadVertexAsync()

in src/CRA.ClientLibrary/Main/CRAWorker.cs [195:244]


        public async Task InstantSideloadVertexAsync(IVertex vertex, string vertexDefinition, string vertexName, bool loadParamFromMetadata = true, object param = null, bool loadConnectionsFromMetadata = true, IEnumerable<VertexConnectionInfo> outRows = null, IEnumerable<VertexConnectionInfo> inRows = null, bool waitForMetadata = false)
        {
            Trace.TraceInformation("Enabling sideload for vertex: " + vertexName + " (" + vertex.GetType().FullName + ")");
            
            if (loadParamFromMetadata)
                _craClient.SideloadVertex(vertex, vertexName);
            else
                _craClient.SideloadVertex(vertex, vertexName, param);

            if (!_localVertexTable.ContainsKey(vertexName))
            {
                await _craClient.LoadVertexAsync(vertexName, vertexDefinition, _workerinstanceName, _localVertexTable, false);

                if (loadConnectionsFromMetadata)
                {
                    if (outRows != null || inRows != null)
                    {
                        throw new Exception("Do not provide connection info if loadConnectionsFromMetadata is set");
                    }
                    outRows = await _connectionInfoProvider.GetAllConnectionsFromVertex(vertexName);
                    inRows = await _connectionInfoProvider.GetAllConnectionsToVertex(vertexName);
                }
                // Do not await this: happens in background
                var _ = RestoreConnections(outRows, inRows);
            }
            // Update metadata table with sideload information
            _craClient.DisableArtifactUploading();
            var taskList = new List<Task>();

            taskList.Add(_craClient.DefineVertexAsync(vertexDefinition, null));
            taskList.Add(_craClient.InstantiateVertexAsync(_workerinstanceName, vertexName, vertexDefinition, param, false, true, true, true));

            if (!loadConnectionsFromMetadata)
            {
                if (outRows != null)
                    foreach (var row in outRows)
                    {
                        taskList.Add(_craClient.ConnectAsync(row.FromVertex, row.FromEndpoint, row.ToVertex, row.ToEndpoint, ConnectionInitiator.FromSide, true, true, false));
                    }

                if (inRows != null)
                    foreach (var row in inRows)
                    {
                        taskList.Add(_craClient.ConnectAsync(row.FromVertex, row.FromEndpoint, row.ToVertex, row.ToEndpoint, ConnectionInitiator.FromSide, true, true, false));
                    }
            }

            if (waitForMetadata)
                await Task.WhenAll(taskList);
        }