shared

package
v0.0.244 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStdGrpcExtension

func IsStdGrpcExtension(pkgName string, providerName string) bool

The standard grpc extension requires special handling as the provided type is is a usage-specific gRPC client class. TODO: make private once Go is fully migrated to the "shared" API.

Types

type DependencyData

type DependencyData struct {
	Name              string
	ProviderName      string
	ProviderInputType ProtoTypeData
	ProviderType      ProviderTypeData
	ProviderLocation  pkggraph.Location
	ProviderInput     SerializedProto
}

type EmbeddedServiceData

type EmbeddedServiceData struct {
	Location pkggraph.Location
	HasDeps  bool
}

type NodeData

type NodeData struct {
	Kind                 schema.Node_Kind
	PackageName          string
	Deps                 []DependencyData
	Providers            []ProviderData
	ImportedInitializers []pkggraph.Location
	Initializer          *PackageInitializerData
}

func PrepareNodeData

func PrepareNodeData(ctx context.Context, loader pkggraph.PackageLoader, loc pkggraph.Location, n *schema.Node, fmwk schema.Framework) (NodeData, error)

type PackageInitializerData

type PackageInitializerData struct {
	// List of packages that need to be initialized before this package. Enforced at runtime.
	InitializeBefore []string
	InitializeAfter  []string
}

type ProtoTypeData

type ProtoTypeData struct {
	Name           string
	SourceFileName string
	Location       pkggraph.Location
	// Distinguishing between message and service types because they need to be imported from different files in node.js
	Kind ProtoTypeKind
}

func PrepareGrpcBackendDep

func PrepareGrpcBackendDep(ctx context.Context, loader pkggraph.PackageLoader, dep *schema.Instantiate) (*ProtoTypeData, error)

TODO: make private once Go is fully migrate to the "shared" API.

type ProtoTypeKind

type ProtoTypeKind int32
const (
	ProtoMessage ProtoTypeKind = iota
	ProtoService
)

type ProviderData

type ProviderData struct {
	Name         string
	Location     pkggraph.Location
	InputType    ProtoTypeData
	ProviderType ProviderTypeData
	ScopedDeps   []DependencyData
}

type ProviderTypeData

type ProviderTypeData struct {
	// Regular case: the user specific the type of the provider in `availableIn`.
	ParsedType *schema.Provides_AvailableIn
	// std/grpc extension: the provider type `<service-name>Client` is generated at runtime.
	// Only can happen within DependencyData.
	Type *ProtoTypeData
	// If true, the provider can return different types dependning on the usage context.\
	// Used to implement gRPC client injection.
	IsParameterized bool
}

Only one of these two fields is set.

type SerializedProto

type SerializedProto struct {
	Content  []byte
	Comments []string
}

type ServerData

type ServerData struct {
	Services             []EmbeddedServiceData
	ImportedInitializers []pkggraph.Location
}

func PrepareServerData

func PrepareServerData(ctx context.Context, loader pkggraph.PackageLoader, loc pkggraph.Location, srv *schema.Server, fmwk schema.Framework) (ServerData, error)

Prepare codegen data for a server.

Jump to

Keyboard shortcuts

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