Resources are serialized as their URN, ID, and package version. Each Pulumi package is expected to register itself with the SDK. The package will be invoked to construct appropriate instances of rehydrated resources. Packages are distinguished by their name and their version. This is the foundation of cross-process resources. Related to #2430. Co-authored-by: Mikhail Shilkov <github@mikhail.io> Co-authored-by: Luke Hoban <luke@pulumi.com> Co-authored-by: Levi Blackstone <levi@pulumi.com>
43 lines
1.9 KiB
C#
43 lines
1.9 KiB
C#
// Copyright 2016-2019, Pulumi Corporation
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Google.Protobuf;
|
|
using Pulumirpc;
|
|
|
|
namespace Pulumi
|
|
{
|
|
public partial class Deployment
|
|
{
|
|
void IDeploymentInternal.RegisterResourceOutputs(Resource resource, Output<IDictionary<string, object?>> outputs)
|
|
{
|
|
// RegisterResourceOutputs is called in a fire-and-forget manner. Make sure we keep track of
|
|
// this task so that the application will not quit until this async work completes.
|
|
_runner.RegisterTask(
|
|
$"{nameof(IDeploymentInternal.RegisterResourceOutputs)}: {resource.GetResourceType()}-{resource.GetResourceName()}",
|
|
RegisterResourceOutputsAsync(resource, outputs));
|
|
}
|
|
|
|
private async Task RegisterResourceOutputsAsync(
|
|
Resource resource, Output<IDictionary<string, object?>> outputs)
|
|
{
|
|
var opLabel = $"monitor.registerResourceOutputs(...)";
|
|
|
|
// The registration could very well still be taking place, so we will need to wait for its URN.
|
|
// Additionally, the output properties might have come from other resources, so we must await those too.
|
|
var urn = await resource.Urn.GetValueAsync().ConfigureAwait(false);
|
|
var props = await outputs.GetValueAsync().ConfigureAwait(false);
|
|
|
|
var serialized = await SerializeAllPropertiesAsync(opLabel, props, true).ConfigureAwait(false);
|
|
Log.Debug($"RegisterResourceOutputs RPC prepared: urn={urn}" +
|
|
(_excessiveDebugOutput ? $", outputs ={JsonFormatter.Default.Format(serialized)}" : ""));
|
|
|
|
await Monitor.RegisterResourceOutputsAsync(new RegisterResourceOutputsRequest
|
|
{
|
|
Urn = urn,
|
|
Outputs = serialized,
|
|
});
|
|
}
|
|
}
|
|
}
|