usecase

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 22 Imported by: 6

Documentation

Overview

Package usecase provides all use-case logics used from each mode. Clients of usecase package must call Inject before all function calls in usecase package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHeader added in v0.8.0

func AddHeader(k, v string)

func CallRPC added in v0.8.0

func CallRPC(ctx context.Context, w io.Writer, rpcName string) error

CallRPC constructs a request with input source such that prompt inputting, stdin or a file. After that, it sends the request to the gRPC server and decodes the response body to res. Note that req and res must be JSON-decodable structs. The output is written to w.

func CallRPCInteractively added in v0.9.0

func CallRPCInteractively(ctx context.Context, w io.Writer, rpcName string, digManually, bytesAsBase64, bytesAsQuotedLiterals, bytesFromFile, rerunPrevious, addRepeatedManually bool) error

func Clear added in v0.8.0

func Clear()

Clear clears all dependencies and states. Usually, it is used for unit testing.

func FormatDescriptor added in v0.9.0

func FormatDescriptor(symbol string) (string, error)

FormatDescriptor formats the descriptor of the passed symbol.

func FormatHeaders added in v0.8.4

func FormatHeaders() (string, error)

FormatHeaders formats all package names.

func FormatMessages added in v0.8.4

func FormatMessages() (string, error)

FormatMessages formats all package names.

func FormatMethod added in v0.9.0

func FormatMethod(fqmn string) (string, error)

FormatMethod formats a method.

func FormatMethods added in v0.9.0

func FormatMethods() (string, error)

FormatMethods formats all method names.

func FormatPackages added in v0.8.4

func FormatPackages() (string, error)

FormatPackages formats all package names.

func FormatServiceDescriptors added in v0.9.0

func FormatServiceDescriptors() (string, error)

FormatServiceDescriptors formats all service descriptors the spec loaded.

func FormatServices added in v0.8.4

func FormatServices() (string, error)

FormatServices formats all service names the spec loaded.

func FormatServicesOld added in v0.9.0

func FormatServicesOld() (string, error)

FormatServicesOld formats all package names. Deprecated: dropped in the next major release.

func GetDomainSourceName added in v0.8.0

func GetDomainSourceName() string

func GetTypeDescriptor added in v0.8.0

func GetTypeDescriptor(typeName string) (interface{}, error)

GetTypeDescriptor gets the descriptor of a type which belongs to the currently selected package.

func Inject added in v0.8.0

func Inject(deps Dependencies)

Inject corresponds an implementation to an interface type. Inject clears the previous states if it exists.

func InjectPartially added in v0.9.0

func InjectPartially(deps Dependencies)

InjectPartially is almost same as the Inject, but injects only non-nil dependencies.

func ListHeaders added in v0.8.0

func ListHeaders() grpc.Headers

func ListPackages added in v0.8.0

func ListPackages() []string

ListPackages lists all package names.

func ListRPCs added in v0.8.0

func ListRPCs(svcName string) ([]*grpc.RPC, error)

ListRPCs lists all RPC belong to the selected service. If svcName is empty, the currently selected service will be used. In this case, ListRPCs doesn't modify the currently selected service.

func ListServices added in v0.8.0

func ListServices() []string

ListServices returns the loaded fully-qualified service names.

func ListServicesOld added in v0.9.0

func ListServicesOld() []string

ListServicesOld returns the services belong to the selected package. The returned service names are NOT fully-qualified.

func ParseFullyQualifiedMethodName added in v0.9.0

func ParseFullyQualifiedMethodName(fqmn string) (fqsn, method string, err error)

ParseFullyQualifiedMethodName parses the passed fully-qualified method as fully-qualified service name and method name. ParseFullyQualifiedMethodName may return these errors:

  • An error described in idl.Spec.RPC method returns.
  • An error if fqmn is not a valid fully-qualified method name form.

func RemoveHeader added in v0.8.0

func RemoveHeader(k string)

func UsePackage added in v0.8.0

func UsePackage(pkgName string) error

UsePackage modifies pkgName as the currently selected package. UsePackage may return these errors:

  • idl.ErrUnknownPackageName: pkgName is not in loaded packages.

func UseService added in v0.8.0

func UseService(svcName string) error

UseService modifies svcName as the currently selected service. UseService may return these errors:

  • ErrPackageUnselected: REPL never call UsePackage.
  • ErrUnknownServiceName: svcName is not in loaded services.

Types

type Dependencies added in v0.9.0

type Dependencies struct {
	Spec              idl.Spec
	Filler            fill.Filler
	InteractiveFiller fill.InteractiveFiller
	GRPCClient        grpc.Client
	ResponseFormatter *format.ResponseFormatter
	ResourcePresenter present.Presenter
}

type ErrorCode added in v0.9.0

type ErrorCode int

ErrorCode represents an application error code.

func (ErrorCode) String added in v0.9.0

func (e ErrorCode) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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