handler

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func New

func New(val Validator, proc []RenderParser, composeFactory func(core.Waiter) WaitComposer) *Handler

New creates a new instance of Handler. It takes three parameters: val of type Validator, proc which is a slice of RenderParser, and composeFactory which is a function that takes a core.Waiter and returns a WaitComposer. It returns a pointer to a Handler.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, params json.RawMessage, waiter core.Waiter, send core.Sender) (map[string]any, error)

Handle processes incoming requests and sends them using the provided sender. It takes a context.Context, a map of parameters, a core.Waiter, and a core.Sender. It returns a map containing the composed results and an error if any occurs during validation or sending requests. It returns an error if the validation of parameters fails or if sending a request fails.

type MockRenderParser added in v0.0.3

type MockRenderParser struct {
	mock.Mock
}

MockRenderParser is an autogenerated mock type for the RenderParser type

func NewMockRenderParser added in v0.0.3

func NewMockRenderParser(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRenderParser

NewMockRenderParser creates a new instance of MockRenderParser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRenderParser) EXPECT added in v0.0.3

func (*MockRenderParser) Name added in v0.1.0

func (_m *MockRenderParser) Name() string

Name provides a mock function with given fields:

func (*MockRenderParser) Parse added in v0.0.3

func (_m *MockRenderParser) Parse(data []byte) (*response.Response, error)

Parse provides a mock function with given fields: data

func (*MockRenderParser) Render added in v0.0.3

func (_m *MockRenderParser) Render(ctx context.Context, reqID string, params []byte, deps map[string]any) (core.Request, error)

Render provides a mock function with given fields: ctx, reqID, params, deps

type MockRenderParser_Expecter added in v0.0.3

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

func (*MockRenderParser_Expecter) Name added in v0.1.0

Name is a helper method to define mock.On call

func (*MockRenderParser_Expecter) Parse added in v0.0.3

func (_e *MockRenderParser_Expecter) Parse(data interface{}) *MockRenderParser_Parse_Call

Parse is a helper method to define mock.On call

  • data []byte

func (*MockRenderParser_Expecter) Render added in v0.0.3

func (_e *MockRenderParser_Expecter) Render(ctx interface{}, reqID interface{}, params interface{}, deps interface{}) *MockRenderParser_Render_Call

Render is a helper method to define mock.On call

  • ctx context.Context
  • reqID string
  • params []byte
  • deps map[string]any

type MockRenderParser_Name_Call added in v0.1.0

type MockRenderParser_Name_Call struct {
	*mock.Call
}

MockRenderParser_Name_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Name'

func (*MockRenderParser_Name_Call) Return added in v0.1.0

func (*MockRenderParser_Name_Call) Run added in v0.1.0

func (*MockRenderParser_Name_Call) RunAndReturn added in v0.1.0

func (_c *MockRenderParser_Name_Call) RunAndReturn(run func() string) *MockRenderParser_Name_Call

type MockRenderParser_Parse_Call added in v0.0.3

type MockRenderParser_Parse_Call struct {
	*mock.Call
}

MockRenderParser_Parse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Parse'

func (*MockRenderParser_Parse_Call) Return added in v0.0.3

func (*MockRenderParser_Parse_Call) Run added in v0.0.3

func (*MockRenderParser_Parse_Call) RunAndReturn added in v0.0.3

type MockRenderParser_Render_Call added in v0.0.3

type MockRenderParser_Render_Call struct {
	*mock.Call
}

MockRenderParser_Render_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Render'

func (*MockRenderParser_Render_Call) Return added in v0.0.3

func (*MockRenderParser_Render_Call) Run added in v0.0.3

func (_c *MockRenderParser_Render_Call) Run(run func(ctx context.Context, reqID string, params []byte, deps map[string]any)) *MockRenderParser_Render_Call

func (*MockRenderParser_Render_Call) RunAndReturn added in v0.0.3

type MockValidator added in v0.0.3

type MockValidator struct {
	mock.Mock
}

MockValidator is an autogenerated mock type for the Validator type

func NewMockValidator added in v0.0.3

func NewMockValidator(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockValidator

NewMockValidator creates a new instance of MockValidator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockValidator) EXPECT added in v0.0.3

func (_m *MockValidator) EXPECT() *MockValidator_Expecter

func (*MockValidator) Validate added in v0.0.3

func (_m *MockValidator) Validate(data []byte) error

Validate provides a mock function with given fields: data

type MockValidator_Expecter added in v0.0.3

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

func (*MockValidator_Expecter) Validate added in v0.0.3

func (_e *MockValidator_Expecter) Validate(data interface{}) *MockValidator_Validate_Call

Validate is a helper method to define mock.On call

  • data []byte

type MockValidator_Validate_Call added in v0.0.3

type MockValidator_Validate_Call struct {
	*mock.Call
}

MockValidator_Validate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Validate'

func (*MockValidator_Validate_Call) Return added in v0.0.3

func (*MockValidator_Validate_Call) Run added in v0.0.3

func (*MockValidator_Validate_Call) RunAndReturn added in v0.0.3

func (_c *MockValidator_Validate_Call) RunAndReturn(run func([]byte) error) *MockValidator_Validate_Call

type MockWaitComposer added in v0.0.3

type MockWaitComposer struct {
	mock.Mock
}

MockWaitComposer is an autogenerated mock type for the WaitComposer type

func NewMockWaitComposer added in v0.0.3

func NewMockWaitComposer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockWaitComposer

NewMockWaitComposer creates a new instance of MockWaitComposer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockWaitComposer) Compose added in v0.0.3

func (_m *MockWaitComposer) Compose() (map[string]any, error)

Compose provides a mock function with given fields:

func (*MockWaitComposer) EXPECT added in v0.0.3

func (*MockWaitComposer) Prepare added in v0.1.0

func (_m *MockWaitComposer) Prepare(_a0 context.Context, _a1 string, _a2 Parser) (string, map[string]any, error)

Prepare provides a mock function with given fields: _a0, _a1, _a2

type MockWaitComposer_Compose_Call added in v0.0.3

type MockWaitComposer_Compose_Call struct {
	*mock.Call
}

MockWaitComposer_Compose_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Compose'

func (*MockWaitComposer_Compose_Call) Return added in v0.0.3

func (*MockWaitComposer_Compose_Call) Run added in v0.0.3

func (*MockWaitComposer_Compose_Call) RunAndReturn added in v0.0.3

func (_c *MockWaitComposer_Compose_Call) RunAndReturn(run func() (map[string]any, error)) *MockWaitComposer_Compose_Call

type MockWaitComposer_Expecter added in v0.0.3

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

func (*MockWaitComposer_Expecter) Compose added in v0.0.3

Compose is a helper method to define mock.On call

func (*MockWaitComposer_Expecter) Prepare added in v0.1.0

func (_e *MockWaitComposer_Expecter) Prepare(_a0 interface{}, _a1 interface{}, _a2 interface{}) *MockWaitComposer_Prepare_Call

Prepare is a helper method to define mock.On call

  • _a0 context.Context
  • _a1 string
  • _a2 Parser

type MockWaitComposer_Prepare_Call added in v0.1.0

type MockWaitComposer_Prepare_Call struct {
	*mock.Call
}

MockWaitComposer_Prepare_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prepare'

func (*MockWaitComposer_Prepare_Call) Return added in v0.1.0

func (*MockWaitComposer_Prepare_Call) Run added in v0.1.0

func (*MockWaitComposer_Prepare_Call) RunAndReturn added in v0.1.0

type Parser

type Parser func([]byte) (*response.Response, error)

type RenderParser

type RenderParser interface {
	Name() string
	Render(ctx context.Context, reqID string, params []byte, deps map[string]any) (core.Request, error)
	Parse(data []byte) (*response.Response, error)
}

type Validator

type Validator interface {
	Validate(data []byte) error
}

type WaitComposer

type WaitComposer interface {
	Prepare(context.Context, string, Parser) (string, map[string]any, error)
	Compose() (map[string]any, error)
}

Jump to

Keyboard shortcuts

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