apimanager

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	GRPCAddress string
	HTTPAddress string
}

Config defines the config structure

func NewConfig

func NewConfig() *Config

NewConfig is used to init config with default values

func (*Config) RegisterFlagsWithPrefix

func (c *Config) RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet)

RegisterFlagsWithPrefix is used to register flags

func (*Config) Validate

func (c *Config) Validate() error

Validate is used to validate config and returns error on failure

type Manager

type Manager struct {
	v1alpha1.UnimplementedMockServer

	logger.Logger
	// contains filtered or unexported fields
}

Manager is the implement of APIManager

func (*Manager) DeleteMockAPI

DeleteMockAPI is used to delete MockAPI

func (*Manager) ListMockAPI

ListMockAPI is used to list MockAPIs

func (*Manager) MatchAPI

func (s *Manager) MatchAPI(host, path, method string) (*v1alpha1.MockAPI, bool)

MatchAPI is used to match MockAPI

func (*Manager) MockResponse

func (s *Manager) MockResponse(ctx context.Context, request *interact.Request) (*interact.Response, error)

MockResponse is used to mock response

func (*Manager) SaveMockAPI

SaveMockAPI is used to create or update MockAPI

func (*Manager) Start

func (s *Manager) Start(ctx context.Context, cancelFunc context.CancelFunc) error

Start is used to start the service

type Provider

type Provider interface {
	v1alpha1.MockServer
	MockResponse(ctx context.Context, request *interact.Request) (*interact.Response, error)
	Start(ctx context.Context, cancelFunc context.CancelFunc) error
}

Provider defines the APIManager interface It is used to manage MockAPI, plug-ins, and generate MockResponse

func New

func New(cfg *Config,
	pluginRegistry pluginregistry.Registry,
	logger logger.Logger, registerer prometheus.Registerer) (Provider, error)

New is used to init service

Jump to

Keyboard shortcuts

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