_go

package module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialConnection

func DialConnection(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)

DialConnection Way for dialing a grpc connection and obtaining a permanent link that is used fairly always available throughout the life cycle of the application.

func HttpClient

func HttpClient(ctx context.Context, opts ...ClientOption) (*http.Client, error)

HttpClient create a http client that

func VersionGo

func VersionGo() string

VersionGo returns the Go runtime version. The returned string has no whitespace, suitable for reporting in header.

func XAntHeader

func XAntHeader(keyval ...string) string

XAntHeader Simple way to add a header to the ant service

Types

type ClientCertSource

type ClientCertSource = func(*tls.CertificateRequestInfo) (*tls.Certificate, error)

ClientCertSource is a function that returns a TLS client certificate to be used when opening TLS connections.

It follows the same semantics as crypto/tls.Config.GetClientCertificate.

type ClientOption

type ClientOption interface {
	Apply(*DialSettings)
}

A ClientOption is an option for a Google API client.

func WithAudiences

func WithAudiences(audience ...string) ClientOption

WithAudiences returns a ClientOption that specifies an audience to be used as the audience field ("aud") for the JWT token authentication.

func WithClientCertSource

func WithClientCertSource(s ClientCertSource) ClientOption

WithClientCertSource returns a ClientOption that specifies a callback function for obtaining a TLS client certificate.

This option is used for supporting mTLS authentication, where the server validates the client certifcate when establishing a connection.

The callback function will be invoked whenever the server requests a certificate from the client. Implementations of the callback function should try to ensure that a valid certificate can be repeatedly returned on demand for the entire life cycle of the transport client. If a nil Certificate is returned (i.e. no Certificate can be obtained), an error should be returned.

func WithEndpoint

func WithEndpoint(url string) ClientOption

WithEndpoint returns a ClientOption that overrides the default endpoint to be used for a service.

func WithGRPCConn

func WithGRPCConn(conn *grpc.ClientConn) ClientOption

WithGRPCConn returns a ClientOption that specifies the gRPC client connection to use as the basis of communications. This option may only be used with services that support gRPC as their communication transport. When used, the WithGRPCConn option takes precedent over all other supplied options.

func WithGRPCDialOption

func WithGRPCDialOption(opt grpc.DialOption) ClientOption

WithGRPCDialOption returns a ClientOption that appends a new grpc.DialOption to an underlying gRPC dial. It does not work with WithGRPCConn.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient returns a ClientOption that specifies the HTTP client to use as the basis of communications. This option may only be used with services that support HTTP as their communication transport. When used, the WithHTTPClient option takes precedent over all other supplied options.

func WithRequestReason

func WithRequestReason(requestReason string) ClientOption

WithRequestReason returns a ClientOption that specifies a reason for making the request, which is intended to be recorded in audit logging. An example reason would be a support-case ticket number.

func WithScopes

func WithScopes(scope ...string) ClientOption

WithScopes returns a ClientOption that overrides the default OAuth2 scopes to be used for a service.

func WithTokenApiKey

func WithTokenApiKey(apiKey string) ClientOption

WithTokenApiKey returns a ClientOption that specifies an API key to be used as the basis for authentication.

func WithTokenEndpoint

func WithTokenEndpoint(tokenEndpoint string) ClientOption

WithTokenEndpoint returns a ClientOption that specifies an API Username to be used as the basis for authentication.

func WithTokenPassword

func WithTokenPassword(tokenPassword string) ClientOption

WithTokenPassword returns a ClientOption that specifies an API Username to be used as the basis for authentication.

func WithTokenSource

func WithTokenSource(s oauth2.TokenSource) ClientOption

WithTokenSource returns a ClientOption that specifies an OAuth2 token source to be used as the basis for authentication.

func WithTokenUsername

func WithTokenUsername(tokenUsername string) ClientOption

WithTokenUsername returns a ClientOption that specifies an API Username to be used as the basis for authentication.

func WithUserAgent

func WithUserAgent(ua string) ClientOption

WithUserAgent returns a ClientOption that sets the User-Agent.

func WithoutAuthentication

func WithoutAuthentication() ClientOption

WithoutAuthentication returns a ClientOption that specifies that no authentication should be used. It is suitable only for testing and for accessing public resources, like public Google Cloud Storage buckets. It is an error to provide both WithoutAuthentication and any of WithTokenApiKey, WithTokenSource, WithCredentialsFile or WithServiceAccountFile.

type CtxServiceKey

type CtxServiceKey string

type DialSettings

type DialSettings struct {
	Endpoint         string
	Scopes           []string
	DefaultScopes    []string
	TokenSource      oauth2.TokenSource
	UserAgent        string
	TokenEndpoint    string
	APIKey           string
	TokenUserName    string
	TokenPassword    string
	Audiences        []string
	DefaultAudience  string
	HTTPClient       *http.Client
	GRPCDialOpts     []grpc.DialOption
	GRPCConn         *grpc.ClientConn
	ClientCertSource func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
	NoAuth           bool
	CustomClaims     map[string]interface{}

	RequestReason string
}

DialSettings holds information needed to establish a connection

func (*DialSettings) GetScopes

func (ds *DialSettings) GetScopes() []string

GetScopes returns the user-provided scopes, if set, or else falls back to the default scopes.

func (*DialSettings) Validate

func (ds *DialSettings) Validate() error

Validate reports an error if ds is invalid.

type JWTInterceptor

type JWTInterceptor struct {
	// contains filtered or unexported fields
}

func (*JWTInterceptor) StreamClientInterceptor

func (jwt *JWTInterceptor) StreamClientInterceptor(
	ctx context.Context,
	desc *grpc.StreamDesc,
	cc *grpc.ClientConn,
	method string,
	streamer grpc.Streamer,
	opts ...grpc.CallOption,
) (grpc.ClientStream, error)

func (*JWTInterceptor) UnaryClientInterceptor

func (jwt *JWTInterceptor) UnaryClientInterceptor(
	ctx context.Context,
	method string,
	req interface{},
	reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption) error

Directories

Path Synopsis
common module
v1
ledger module
v1
Code generated by MockGen.
Code generated by MockGen.
lostid module
notification module
ocr module
partition module
payment module
profile module
property module
settings module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL