pulumi/sdk/proto/go/callback_grpc.pb.go

108 lines
3.7 KiB
Go
Raw Normal View History

Engine support for remote transforms (#15290) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> This adds support to the engine for "remote transformations". A transform is "remote" because it is being invoked via the engine on receiving a resource registration, rather than being ran locally in process before sending a resource registration. These transforms can also span multiple process boundaries, e.g. a transform function in a user program, then a transform function in a component library, both running for a resource registered by another component library. The underlying new feature here is the idea of a `Callback`. The expectation is we're going to use callbacks for multiple features so these are _not_ defined in terms of transformations. A callback is an untyped byte array (usually will be a protobuf message), plus an address to define which server should be invoked to do the callback, and a token to identify it. A language sdk can start up and serve a `Callbacks` service, keep a mapping of tokens to in-process functions (currently just using UUID's for this), and then pass that service address and token to the engine to be invoked later on. The engine uses these callbacks to track transformations callbacks per resource, and on a new resource registrations invokes each relevant callback with the resource properties and options, having new properties and options returned that are then passed to the next relevant transform callback until all have been called and the engine has the final resource state and options to use. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-02-21 16:30:46 +00:00
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.20.1
// source: pulumi/callback.proto
package pulumirpc
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// CallbacksClient is the client API for Callbacks service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type CallbacksClient interface {
// Invoke invokes a given callback, identified by its token.
Invoke(ctx context.Context, in *CallbackInvokeRequest, opts ...grpc.CallOption) (*CallbackInvokeResponse, error)
}
type callbacksClient struct {
cc grpc.ClientConnInterface
}
func NewCallbacksClient(cc grpc.ClientConnInterface) CallbacksClient {
return &callbacksClient{cc}
}
func (c *callbacksClient) Invoke(ctx context.Context, in *CallbackInvokeRequest, opts ...grpc.CallOption) (*CallbackInvokeResponse, error) {
out := new(CallbackInvokeResponse)
err := c.cc.Invoke(ctx, "/pulumirpc.Callbacks/Invoke", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CallbacksServer is the server API for Callbacks service.
// All implementations must embed UnimplementedCallbacksServer
// for forward compatibility
type CallbacksServer interface {
// Invoke invokes a given callback, identified by its token.
Invoke(context.Context, *CallbackInvokeRequest) (*CallbackInvokeResponse, error)
mustEmbedUnimplementedCallbacksServer()
}
// UnimplementedCallbacksServer must be embedded to have forward compatible implementations.
type UnimplementedCallbacksServer struct {
}
func (UnimplementedCallbacksServer) Invoke(context.Context, *CallbackInvokeRequest) (*CallbackInvokeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Invoke not implemented")
}
func (UnimplementedCallbacksServer) mustEmbedUnimplementedCallbacksServer() {}
// UnsafeCallbacksServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CallbacksServer will
// result in compilation errors.
type UnsafeCallbacksServer interface {
mustEmbedUnimplementedCallbacksServer()
}
func RegisterCallbacksServer(s grpc.ServiceRegistrar, srv CallbacksServer) {
s.RegisterService(&Callbacks_ServiceDesc, srv)
}
func _Callbacks_Invoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CallbackInvokeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CallbacksServer).Invoke(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pulumirpc.Callbacks/Invoke",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CallbacksServer).Invoke(ctx, req.(*CallbackInvokeRequest))
}
return interceptor(ctx, in, info, handler)
}
// Callbacks_ServiceDesc is the grpc.ServiceDesc for Callbacks service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Callbacks_ServiceDesc = grpc.ServiceDesc{
ServiceName: "pulumirpc.Callbacks",
HandlerType: (*CallbacksServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Invoke",
Handler: _Callbacks_Invoke_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pulumi/callback.proto",
}