model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: MIT Imports: 15 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 {
	Services []*Service

	TestName     string
	TestDuration time.Duration
	TestRunners  int

	Repeats              int
	SleepBetweenRequests time.Duration
}

Config is config.

func (*Config) Run

func (c *Config) Run()

Run runs the simulation.

func (*Config) Start

func (c *Config) Start() error

Start starts the simulation.

func (*Config) Stop

func (c *Config) Stop()

Stop stops the simulation.

func (*Config) Validate

func (c *Config) Validate(r *Registry) error

Validate performs validation and sets defaults.

type Dependencies

type Dependencies struct {
	Seq     Sequence    `json:",omitempty"`
	Par     *Parallel   `json:",omitempty"`
	Service *ServiceDep `json:",omitempty"`
}

Dependencies describes dependencies.

func (*Dependencies) Call

func (d *Dependencies) Call(ctx context.Context, tracer opentracing.Tracer) error

Call makes calls to all dependencies.

func (*Dependencies) Validate

func (d *Dependencies) Validate(r *Registry) error

Validate performs validation and sets defaults.

type Endpoint

type Endpoint struct {
	Name    string
	Perf    *Perf         `json:",omitempty"`
	Depends *Dependencies `json:",omitempty"`
	// contains filtered or unexported fields
}

Endpoint describes an endpoint

func (*Endpoint) NewInstance

func (e *Endpoint) NewInstance(serviceInst *ServiceInstance) *EndpointInstance

NewInstance creates a new instance of endpoint for

func (*Endpoint) Validate

func (e *Endpoint) Validate(s *Service, r *Registry) error

Validate performs validation and sets defaults.

type EndpointInstance

type EndpointInstance struct {
	Endpoint
	// contains filtered or unexported fields
}

EndpointInstance implements an endpoint in a single instance of a service.

func (*EndpointInstance) Call

func (e *EndpointInstance) Call(ctx context.Context, tracer opentracing.Tracer) error

Call makes a call to this endpoint.

func (*EndpointInstance) ServeHTTP

func (e *EndpointInstance) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Latency

type Latency struct {
	Mean, StdDev time.Duration
}

Latency contains parameters for simulating latency

type Parallel

type Parallel struct {
	Items  []Dependencies
	MaxPar int `json:",omitempty"`
}

Parallel describes parallel dependencies.

func (*Parallel) Call

func (p *Parallel) Call(ctx context.Context, tracer opentracing.Tracer) error

Call makes calls to all dependencies.

func (*Parallel) Validate

func (p *Parallel) Validate(r *Registry) error

Validate performs validation and sets defaults.

type Perf

type Perf struct {
	Latency     *Latency
	FailureRate float64
}

Perf controls service performance.

func (*Perf) Apply

func (p *Perf) Apply(context.Context) error

Apply executes the instructions specified in Perf.

func (*Perf) Validate

func (p *Perf) Validate(r *Registry) error

Validate performs validation and sets defaults.

type Registry

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

Registry stores all services.

func (*Registry) RegisterServices

func (r *Registry) RegisterServices(s []*Service) error

RegisterServices stores all services in Registry.

func (*Registry) Service

func (r *Registry) Service(name string) *Service

Service looks up a service by name.

type Sequence

type Sequence []Dependencies

Sequence describes sequential dependencies.

func (Sequence) Call

func (s Sequence) Call(ctx context.Context, tracer opentracing.Tracer) error

Call makes calls to all dependencies.

func (Sequence) Validate

func (s Sequence) Validate(r *Registry) error

Validate performs validation and sets defaults.

type Service

type Service struct {
	Name      string
	Endpoints []*Endpoint `json:",omitempty"`
	Count     int         `json:",omitempty"`
	// contains filtered or unexported fields
}

Service is service.

func (*Service) DefaultEndpoint

func (s *Service) DefaultEndpoint() *Endpoint

DefaultEndpoint returns default endpoint for this service (always the first). If none are defined, it creates one.

func (*Service) Endpoint

func (s *Service) Endpoint(name string) *Endpoint

Endpoint returns an endpoint for the service, or nil if not found.

func (*Service) NextServerURL

func (s *Service) NextServerURL() string

NextServerURL returns the URL of one of the servers, in round-robin fashion.

func (*Service) Start

func (s *Service) Start() error

Start starts HTTP servers for this service.

func (*Service) Stop

func (s *Service) Stop()

Stop stops HTTP servers for this service.

func (*Service) Validate

func (s *Service) Validate(r *Registry) error

Validate validates Service and sets defaults.

type ServiceDep

type ServiceDep struct {
	Name     string
	Endpoint string `json:",omitempty"`
	// contains filtered or unexported fields
}

ServiceDep describes dependency on a specific service, and optionally endpoint.

func (*ServiceDep) Call

func (s *ServiceDep) Call(ctx context.Context, tracer opentracing.Tracer) error

Call makes call to dependency service.

func (*ServiceDep) Validate

func (s *ServiceDep) Validate(r *Registry) error

Validate performs validation and sets defaults.

type ServiceInstance

type ServiceInstance struct {
	Endpoints []*EndpointInstance
	// contains filtered or unexported fields
}

ServiceInstance represents a single instance of a service.

func (*ServiceInstance) Stop

func (inst *ServiceInstance) Stop()

Stop shuts down the HTTP server and closes the tracer.

Jump to

Keyboard shortcuts

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