Documentation
¶
Index ¶
- Variables
- func IsNotFoundError(err error) bool
- type ResourceModifier
- type RunServerFunctionRequest
- func (r *RunServerFunctionRequest) GetComposed(name string, target runtime.Object) error
- func (r *RunServerFunctionRequest) GetComposite(target runtime.Object) error
- func (r *RunServerFunctionRequest) GetInput(target any) error
- func (r *RunServerFunctionRequest) GetNativeRequest() *fnapi.RunFunctionRequest
- type RunServerFunctionResponse
- func (r *RunServerFunctionResponse) GetComposed(name string, target runtime.Object) error
- func (r *RunServerFunctionResponse) GetComposite(target runtime.Object) error
- func (r *RunServerFunctionResponse) SetComposed(name string, o runtime.Object, mods ...ResourceModifier) error
- func (r *RunServerFunctionResponse) SetComposedRaw(name string, res *fnapi.Resource)
- func (r *RunServerFunctionResponse) SetComposite(o runtime.Object, mods ...ResourceModifier) error
- func (r *RunServerFunctionResponse) SetCompositeRaw(res *fnapi.Resource)
- func (r *RunServerFunctionResponse) SetContextField(key string, value any) error
- func (r *RunServerFunctionResponse) SetNativeResults(results []*fnapi.Result)
- type Server
- type ServerFunction
- type ServerFunctionRequest
- type ServerFunctionResponse
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
var ( WithReadyIsReady = WithReady(fnapi.Ready_READY_TRUE) WithReadyIsNotReady = WithReady(fnapi.Ready_READY_FALSE) WithReadyUnspecified = WithReady(fnapi.Ready_READY_UNSPECIFIED) )
WithReady shorthand
Functions ¶
func IsNotFoundError ¶
Types ¶
type ResourceModifier ¶
ResourceModifier applies modifications to a bare-metal Crossplane function resource.
func WithConnectionDetails ¶
func WithConnectionDetails(connectionDetails map[string][]byte) ResourceModifier
WithConnectionDetails sets the given connection details to a resource.
func WithReady ¶
func WithReady(ready fnapi.Ready) ResourceModifier
WithReady applies the desired ready state to a resource.
type RunServerFunctionRequest ¶
type RunServerFunctionRequest struct {
Req *fnapi.RunFunctionRequest
ServerInput *v1alpha1.ServerInput
}
func (*RunServerFunctionRequest) GetComposed ¶
func (r *RunServerFunctionRequest) GetComposed(name string, target runtime.Object) error
func (*RunServerFunctionRequest) GetComposite ¶
func (r *RunServerFunctionRequest) GetComposite(target runtime.Object) error
func (*RunServerFunctionRequest) GetInput ¶
func (r *RunServerFunctionRequest) GetInput(target any) error
func (*RunServerFunctionRequest) GetNativeRequest ¶
func (r *RunServerFunctionRequest) GetNativeRequest() *fnapi.RunFunctionRequest
type RunServerFunctionResponse ¶
type RunServerFunctionResponse struct {
DesiredComposite *fnapi.Resource
DesiredComposed map[string]*fnapi.Resource
DesiredContext *structpb.Struct
Results []*fnapi.Result
}
func (*RunServerFunctionResponse) GetComposed ¶
func (r *RunServerFunctionResponse) GetComposed(name string, target runtime.Object) error
func (*RunServerFunctionResponse) GetComposite ¶
func (r *RunServerFunctionResponse) GetComposite(target runtime.Object) error
func (*RunServerFunctionResponse) SetComposed ¶
func (r *RunServerFunctionResponse) SetComposed(name string, o runtime.Object, mods ...ResourceModifier) error
func (*RunServerFunctionResponse) SetComposedRaw ¶
func (r *RunServerFunctionResponse) SetComposedRaw(name string, res *fnapi.Resource)
func (*RunServerFunctionResponse) SetComposite ¶
func (r *RunServerFunctionResponse) SetComposite(o runtime.Object, mods ...ResourceModifier) error
func (*RunServerFunctionResponse) SetCompositeRaw ¶
func (r *RunServerFunctionResponse) SetCompositeRaw(res *fnapi.Resource)
func (*RunServerFunctionResponse) SetContextField ¶
func (r *RunServerFunctionResponse) SetContextField(key string, value any) error
func (*RunServerFunctionResponse) SetNativeResults ¶
func (r *RunServerFunctionResponse) SetNativeResults(results []*fnapi.Result)
type Server ¶
type Server struct {
fnapi.UnimplementedFunctionRunnerServiceServer
// contains filtered or unexported fields
}
Server is a special Crossplane function which acts as a router that distributes request among several subroutines (aka server functions).
A server receives a dedicated input payload by the composition that tells the server which subroutine to call.
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
NewServer create a new Server instance that implements the Crossplane Function interface and is able to serve multiple subfunctions (aka server functions) at the same time.
ServerFunctions are registered via the WithFunction option:
server.NewServer(
server.WithFunction(&MyFunction{})
server.WithFunction(&MyOtherFunction{})
// ...
)
func (*Server) RunFunction ¶
func (s *Server) RunFunction(ctx context.Context, req *fnapi.RunFunctionRequest) (*fnapi.RunFunctionResponse, error)
type ServerFunction ¶
type ServerFunction interface {
// Run executes the ServerFunction for the given request.
Run(ctx context.Context, req ServerFunctionRequest, res ServerFunctionResponse) error
}
A ServerFunction is a high-level subroutine of native Crossplane Go function.
type ServerFunctionRequest ¶
type ServerFunctionRequest interface {
// GetNativeRequest returns the native function request of the
// underlying Crossplane function-sdk-go.
GetNativeRequest() *fnapi.RunFunctionRequest
// GetInput for this server function.
//
// Note that this is not the input of the Crossplane function-sdk-go.
// To receive that use GetNativeRequest().GetInput().
GetInput(target any) error
// GetComposite copies the current state of the composite resource
// into the given target object.
GetComposite(target runtime.Object) error
// GetComposed copies the current state of the composed resource identified
// by the given name.
//
// If a no composed resource with the given name exists, target remains
// unchanged.
GetComposed(name string, target runtime.Object) error
}
ServerFunctionRequest provides ways to easily the request payload of a ServerFunction call.
type ServerFunctionResponse ¶
type ServerFunctionResponse interface {
// SetComposite save the given object as desired state of the composite
// resource for the given name.
SetComposite(o runtime.Object, mods ...ResourceModifier) error
// GetComposite gets the current state of the composite resource of this
// response and writes its contents into the given target object.
GetComposite(target runtime.Object) error
// SetCompositeRaw sets the desired response state directly using the
// native SDK types.
//
// This is useful if the desired resource state already exists as a native
// type so there is no need to work with runtime.Objects.
SetCompositeRaw(res *fnapi.Resource)
// SetComposed saves the given composed object as desired composed object
// identified by the given name for this function's response.
SetComposed(name string, o runtime.Object, mods ...ResourceModifier) error
// GetComposed looks up the composed resource in the current response object
// and writes its contents into the given target object.
GetComposed(name string, target runtime.Object) error
// SetComposedRaw sets the desired composed resource state directly using
// the native SDK types.
//
// This is useful if the desired resource state already exists as a native
// type so there is no need to work with runtime.Objects.
SetComposedRaw(name string, res *fnapi.Resource)
// SetContextField sets the value of the context field key to the given
// value. The passed value must be convertable to protobuf.
SetContextField(key string, value any) error
// SetNativeResults of the underlying SDK requests.
SetNativeResults(results []*fnapi.Result)
}
ServerFunctionResponse provides ways to easily define the response payload of a ServerFunction call.
type ServerOption ¶
type ServerOption func(server *Server)
ServerOption that configures a function Server.
func WithFunction ¶
func WithFunction(name string, fn ServerFunction) ServerOption
WithFunction registeres a ServerFunction at a Server with a given name.
Directories
¶
| Path | Synopsis |
|---|---|
|
apis
|
|
|
v1alpha1
+kubebuilder:object:generate=true Package v1alpha1 is the v1alpha1 version of the server.fn.crossplane.io API.
|
+kubebuilder:object:generate=true Package v1alpha1 is the v1alpha1 version of the server.fn.crossplane.io API. |
|
examples
|
|
|
simple
command
Package main implements a Server Composition Function that serves multiple ServerFunctions.
|
Package main implements a Server Composition Function that serves multiple ServerFunctions. |