GcpConnectionResolver

Helper class used to retrieve Google connection and credential parameters, validate them and compose a GcpConnectionParams value.

Description

Helper class to retrieve Google connection and credential parameters, validate them and compose a GcpConnectionParams value.

Configuration parameters

  • connections:
    • uri: full connection uri with specific app and function name
    • protocol: connection protocol
    • project_id: is your Google Cloud Platform project ID
    • region: is the region where your function is deployed
    • function_name: is the name of the HTTP function you deployed
  • credentials:
    • account: the service account name
    • auth_token: Google-generated ID token or null if using custom auth

References

  • *:credential-store:*:*:1.0 - (optional) credential stores to resolve credentials.

Constructors

NewGcpConnectionResolver

Creates new instance of GcpConnectionResolver

NewGcpConnectionResolver() *GcpConnectionResolver

Fields

connectionResolver

Connection resolver.

connectionResolver: *ConnectionResolver

credentialResolver

Credential resolver.

credentialResolver: *CredentialResolver

Instance methods

Configure

Configures a component by passing its configuration parameters.

(c *GcpConnectionResolver) Configure(ctx context.Context, config *cconf.ConfigParams)

  • ctx: context.Context - operation context.
  • config: *ConfigParams - configuration parameters to be set.

Resolve

Resolves connection and credential parameters and generates a single GcpConnectionParams value.

(c *GcpConnectionResolver) Resolve(correlationId string) (GcpConnectionParams, error)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • returns: (GcpConnectionParams, error) - receives an GcpConnectionParams value or error.

SetReferences

Sets references to dependent components.

(c *GcpConnectionResolver) SetReferences(ctx context.Context, references IReferences)

  • ctx: context.Context - operation context.
  • references: IReferences - references to locate the component’s dependencies.

Examples

config := config.NewConfigParamsFromTuples(
	"connection.uri", "http://east-my_test_project.cloudfunctions.net/myfunction",
	"connection.protocol", "http",
	"connection.region", "east",
	"connection.function", "myfunction",
	"connection.project_id", "my_test_project",
	"credential.auth_token", "1234",
)
ctx := context.Background()
connectionResolver := connect.NewGcpConnectionResolver()
connectionResolver.Configure(ctx, config)
connectionResolver.SetReferences(ctx, references)
connectionParams, _ := connectionResolver.Resolve("123")

See also