base

package
v0.0.0-...-483e9f6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](s []T, e T) bool

func DefaultServeMuxOptions

func DefaultServeMuxOptions(s ...GRPCServer) []runtime.ServeMuxOption

func EmbedFSToOSFS

func EmbedFSToOSFS(prefix string, fs embed.FS, fsDirectory string) ([]string, error)

EmbedFSToOSFS re-creates the structure of the embed.FS in the OS filesystem. It is mostly useful for testing but other uses are possible. This function takes a prefix / directory and an embed.FS and creates the corresponding directory structure in the OS filesystem. Returns all created file paths.

func GetTemporalClientFromFlags

func GetTemporalClientFromFlags(ctx *cli.Context, opts client.Options) (client.Client, error)

GetTemporalClientFromFlags gets the temporal client from the cli flags.

func GithubGrpcInterceptor

func GithubGrpcInterceptor(team string) (grpc.UnaryServerInterceptor, error)

GithubGrpcInterceptor is a gRPC interceptor that checks for a valid GitHub token and that the user is in the given team

func LogErrorf

func LogErrorf(format string, args ...interface{})

LogErrorf logs an error message todo(mustafa): remove this and use slog.Error properly deprecated

func NameGen

func NameGen(prefix string) string

func NewDBArgs

func NewDBArgs(keyval ...any) *orderedmap.OrderedMap[string, any]

func NewTemporalClient

func NewTemporalClient(host string, namespace string, taskQueue string, opts client.Options) (client.Client, error)

func Pointer

func Pointer[T any](v T) *T

func RareUseChangeDefault

func RareUseChangeDefault(envVar string, newDefault string)

RareUseChangeDefault changes the default value of an arbitrary environment variable.

func SliceToPB

func SliceToPB[T any, U internalGetPb[T]](slice []U) []T

func SqlNullString

func SqlNullString(s sql.NullString) *wrapperspb.StringValue

func SqlNullTime

func SqlNullTime(t sql.NullTime) *timestamppb.Timestamp

func WithDatabaseFlags

func WithDatabaseFlags(appName string) []cli.Flag

func WithFlags

func WithFlags(flags ...[]cli.Flag) []cli.Flag

func WithGatewayFlags

func WithGatewayFlags(defaultPort int) []cli.Flag

func WithGrpcFlags

func WithGrpcFlags(defaultPort int) []cli.Flag

func WithStorageFlags

func WithStorageFlags() []cli.Flag

WithStorageFlags adds the storage flags to the app.

func WithTemporalFlags

func WithTemporalFlags(defaultNamespace string, defaultTaskQueue string) []cli.Flag

Types

type DB

type DB struct {
	*pika.PostgreSQL
}

func GetDBFromFlags

func GetDBFromFlags(ctx *cli.Context) *DB

GetDBFromFlags gets the database from the cli flags.

func NewDB

func NewDB(databaseURL string) (*DB, error)

type EnvVar

type EnvVar string
const (
	EnvVarGRPCPort                EnvVar = "GRPC_PORT"
	EnvVarGatewayPort             EnvVar = "GATEWAY_PORT"
	EnvVarDatabaseURI             EnvVar = "DATABASE_URI"
	EnvVarTemporalNamespace       EnvVar = "TEMPORAL_NAMESPACE"
	EnvVarTemporalAddress         EnvVar = "TEMPORAL_ADDRESS"
	EnvVarTemporalTaskQueue       EnvVar = "TEMPORAL_TASK_QUEUE"
	EnvVarStorageEndpoint         EnvVar = "STORAGE_ENDPOINT"
	EnvVarStorageConnectionString EnvVar = "STORAGE_CONNECTION_STRING"
	EnvVarStorageRegion           EnvVar = "STORAGE_REGION"
	EnvVarStorageSecure           EnvVar = "STORAGE_SECURE"
	EnvVarStoragePathStyle        EnvVar = "STORAGE_PATH_STYLE"
)

type FrontendInfo

type FrontendInfo struct {
	// NoRun is a flag to disable running the frontend server
	NoRun bool

	// MuxHandler is the HTTP handler (can be nil)
	MuxHandler http.Handler

	// Title to add to the HTML page
	Title string

	// Port is the port to serve the frontend on
	Port int

	// Self is the URL to the frontend server
	Self string

	// NoAuth is a flag to disable authentication
	NoAuth bool

	// AllowUnauthenticated is a flag to allow unauthenticated users
	AllowUnauthenticated bool

	// OIDCIssuer is the issuer to use for authentication
	OIDCIssuer string

	// OIDCClientID is the client ID to use for authentication
	OIDCClientID string

	// OIDCClientSecret is the client secret to use for authentication
	OIDCClientSecret string

	// OIDCGroup is the group to check for authentication
	OIDCGroup string

	// OIDCUserInfoOverride is a flag to override the userinfo endpoint
	// todo(mustafa): we don't need to use it yet since RESF deploys cluster external Keycloak.
	OIDCUserInfoOverride string
}

type GRPCServer

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

func NewGRPCServer

func NewGRPCServer(opts ...GRPCServerOption) (*GRPCServer, error)

NewGRPCServer creates a new gRPC-server with gRPC-gateway, default interceptors and exposed Prometheus metrics.

func (*GRPCServer) GatewayEndpoints

func (g *GRPCServer) GatewayEndpoints(registerEndpoints ...GrpcEndpointRegister) error

func (*GRPCServer) GatewayMux

func (g *GRPCServer) GatewayMux() *runtime.ServeMux

func (*GRPCServer) RegisterService

func (g *GRPCServer) RegisterService(register func(*grpc.Server))

func (*GRPCServer) Start

func (g *GRPCServer) Start() error

type GRPCServerOption

type GRPCServerOption func(*GRPCServer)

func FlagsToGRPCServerOptions

func FlagsToGRPCServerOptions(ctx *cli.Context) []GRPCServerOption

FlagsToGRPCServerOptions converts the cli flags to gRPC server options.

func WithDialOptions

func WithDialOptions(opts ...grpc.DialOption) GRPCServerOption

WithDialOptions sets the gRPC dial options. (Append)

func WithGRPCPort

func WithGRPCPort(port int) GRPCServerOption

WithGRPCPort sets the gRPC port for the gRPC server.

func WithGatewayPort

func WithGatewayPort(port int) GRPCServerOption

WithGatewayPort sets the gRPC-gateway port for the gRPC server.

func WithIncomingHeaders

func WithIncomingHeaders(headers ...string) GRPCServerOption

WithIncomingHeaders sets the incoming headers for the gRPC-gateway. (Append)

func WithMuxOptions

func WithMuxOptions(opts ...runtime.ServeMuxOption) GRPCServerOption

WithMuxOptions sets the gRPC-gateway mux options. (Append)

func WithNoGRPCGateway

func WithNoGRPCGateway() GRPCServerOption

WithNoGRPCGateway disables the gRPC-gateway for the gRPC server.

func WithNoMetrics

func WithNoMetrics() GRPCServerOption

WithNoMetrics disables the Prometheus metrics for the gRPC server.

func WithOutgoingHeaders

func WithOutgoingHeaders(headers ...string) GRPCServerOption

WithOutgoingHeaders sets the outgoing headers for the gRPC-gateway. (Append)

func WithServeMuxAdditionalHeaders

func WithServeMuxAdditionalHeaders(headers ...string) GRPCServerOption

WithServeMuxAdditionalHeaders sets additional headers for the gRPC-gateway. (incoming)

func WithServerOptions

func WithServerOptions(opts ...grpc.ServerOption) GRPCServerOption

WithServerOptions sets the gRPC server options. (Append)

func WithStreamInterceptors

func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) GRPCServerOption

WithStreamInterceptors sets the gRPC stream interceptors. (Append)

func WithTimeout

func WithTimeout(timeout time.Duration) GRPCServerOption

WithTimeout sets the timeout for the gRPC server.

func WithUnaryInterceptors

func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) GRPCServerOption

WithUnaryInterceptors sets the gRPC unary interceptors. (Append)

type GrpcEndpointRegister

type GrpcEndpointRegister func(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

type Pika

type Pika[T any] interface {
	pika.QuerySet[T]

	U(x any) error
	F(keyval ...any) Pika[T]
	D(x any) error
	Transaction(ctx context.Context) (Pika[T], error)
	Commit() error
}

func Q

func Q[T any](db *DB) Pika[T]

Directories

Path Synopsis
s3

Jump to

Keyboard shortcuts

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