daemon

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package daemon implements the RPC server side interface to remotely manage external Pact dependencies: The Pact Mock Service and Provider Verification "binaries."

See https://github.com/pact-foundation/pact-provider-verifier and https://github.com/bethesque/pact-mock_service for more on the Ruby "binaries".

NOTE: The ultimate goal here is to replace the Ruby dependencies with a shared library (Pact Reference - (https://github.com/pact-foundation/pact-reference/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

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

Daemon wraps the commands for the RPC server.

func NewDaemon

func NewDaemon(MockServiceManager Service, verificationServiceManager Service) *Daemon

NewDaemon returns a new Daemon with all instance variables initialised.

func (Daemon) ListServers

func (d Daemon) ListServers(request types.MockServer, reply *types.PactListResponse) error

ListServers returns a slice of all running types.MockServers.

func (Daemon) Shutdown

func (d Daemon) Shutdown()

Shutdown ensures all services are cleanly destroyed.

func (Daemon) StartDaemon

func (d Daemon) StartDaemon(port int, network string, address string)

StartDaemon starts the daemon RPC server.

func (Daemon) StartServer

func (d Daemon) StartServer(request types.MockServer, reply *types.MockServer) error

StartServer starts a mock server and returns a pointer to atypes.MockServer struct.

func (Daemon) StopDaemon

func (d Daemon) StopDaemon(request string, reply *string) error

StopDaemon allows clients to programmatically shuts down the running Daemon via RPC.

func (Daemon) StopServer

func (d Daemon) StopServer(request types.MockServer, reply *types.MockServer) error

StopServer stops the given mock server.

func (Daemon) VerifyProvider

func (d Daemon) VerifyProvider(request types.VerifyRequest, reply *types.CommandResponse) error

VerifyProvider runs the Pact Provider Verification Process.

type MockService added in v0.0.2

type MockService struct {
	ServiceManager
}

MockService is a wrapper for the Pact Mock Service.

func (*MockService) NewService added in v0.0.2

func (m *MockService) NewService(args []string) Service

NewService creates a new MockService with default settings.

type Service

type Service interface {
	Setup()
	Stop(pid int) (bool, error)
	List() map[int]*exec.Cmd
	Start() *exec.Cmd
	Run(io.Writer) (*exec.Cmd, error)
	NewService(args []string) Service
}

Service is a process wrapper for 3rd party binaries. It will spawn an instance of the binary and manage the life-cycle and IO of the process.

type ServiceManager

type ServiceManager struct {
	Command string

	Args []string
	Env  []string
	// contains filtered or unexported fields
}

ServiceManager is the default implementation of the Service interface.

func (*ServiceManager) List

func (s *ServiceManager) List() map[int]*exec.Cmd

List all Service PIDs.

func (*ServiceManager) Run

func (s *ServiceManager) Run(w io.Writer) (*exec.Cmd, error)

Run runs a service synchronously and log its output to the given Pipe.

func (*ServiceManager) Setup

func (s *ServiceManager) Setup()

Setup the Management services.

func (*ServiceManager) Start

func (s *ServiceManager) Start() *exec.Cmd

Start a Service and log its output.

func (*ServiceManager) Stop

func (s *ServiceManager) Stop(pid int) (bool, error)

Stop a Service and returns the exit status.

type ServiceMock

type ServiceMock struct {
	Command string

	Args                []string
	ServiceStopResult   bool
	ServiceStopError    error
	ServiceList         map[int]*exec.Cmd
	ServiceStartCmd     *exec.Cmd
	ServiceStartCount   int
	ServicePort         int
	ServiceStopCount    int
	ServicesSetupCalled bool

	// ExecFunc sets the function to run when starting commands
	ExecFunc func() *exec.Cmd
	// contains filtered or unexported fields
}

ServiceMock is the mock implementation of the Service interface.

func (*ServiceMock) List

func (s *ServiceMock) List() map[int]*exec.Cmd

List all Service PIDs.

func (*ServiceMock) NewService

func (s *ServiceMock) NewService(args []string) Service

NewService creates a new MockService with default settings.

func (*ServiceMock) Run

func (s *ServiceMock) Run(w io.Writer) (*exec.Cmd, error)

Run runs a service synchronously and log its output to the given Pipe.

func (*ServiceMock) Setup

func (s *ServiceMock) Setup()

Setup the Management services.

func (*ServiceMock) Start

func (s *ServiceMock) Start() *exec.Cmd

Start a Service and log its output.

func (*ServiceMock) Stop

func (s *ServiceMock) Stop(pid int) (bool, error)

Stop a Service and returns the exit status.

type VerificationService

type VerificationService struct {
	ServiceManager
}

VerificationService is a wrapper for the Pact Provider Verifier Service.

func (*VerificationService) NewService

func (m *VerificationService) NewService(args []string) Service

NewService creates a new VerificationService with default settings. Arguments allowed:

		--provider-base-url
		--pact-urls
		--provider-states-url
		--provider-states-setup-url
		--broker-username
		--broker-password
   --publish_verification_results
   --provider_app_version

Jump to

Keyboard shortcuts

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