services

package
v0.0.0-...-6b385f4 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockNowValue

func MockNowValue(p TimeProvider) time.Time

func Register

func Register(container *dig.Container) error

Types

type ItemEventsKafkaReader

type ItemEventsKafkaReader struct {
	*kafka.Reader
	// contains filtered or unexported fields
}

func (*ItemEventsKafkaReader) ReadLastOffset

func (r *ItemEventsKafkaReader) ReadLastOffset(ctx context.Context) (int64, error)

ReadLastOffset reads the last offset from the kafka topic. This is going to be an offset for the next message produced.

type ItemEventsKafkaReaderDeps

type ItemEventsKafkaReaderDeps struct {
	dig.In

	RootLogger *slog.Logger

	// config
	KafkaTopic    string        `name:"config.kafka.itemEventsTopic"`
	KafkaAddress  string        `name:"config.kafka.address"`
	ReaderMaxWait time.Duration `name:"config.kafka.readerMaxWait"`

	// services
	*ShutdownHooks

	// package internal
	KafkaLeaderDialer kafkaLeaderDialer
}

type ItemEventsKafkaWriter

type ItemEventsKafkaWriter struct {
	*kafka.Writer
}

func (ItemEventsKafkaWriter) Close

func (w ItemEventsKafkaWriter) Close() error

We may want to remove this once below PR is merged and new version is released: https://github.com/segmentio/kafka-go/pull/1341

type ItemEventsKafkaWriterDeps

type ItemEventsKafkaWriterDeps struct {
	dig.In

	RootLogger *slog.Logger

	// config
	KafkaTopic                  string        `name:"config.kafka.itemEventsTopic"`
	KafkaAddress                string        `name:"config.kafka.address"`
	KafkaAllowAutoTopicCreation bool          `name:"config.kafka.allowAutoTopicCreation"`
	KafkaWriteTimeout           time.Duration `name:"config.kafka.writeTimeout"`
	KafkaMaxWriteAttempts       int           `name:"config.kafka.maxWriteAttempts"`

	// services
	*ShutdownHooks
}

type MockKafkaReader

type MockKafkaReader struct {
	mock.Mock
}

MockKafkaReader is an autogenerated mock type for the mockKafkaReader type

func NewMockKafkaReader

func NewMockKafkaReader(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockKafkaReader

NewMockKafkaReader creates a new instance of MockKafkaReader. 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 (*MockKafkaReader) Close

func (_m *MockKafkaReader) Close() error

Close provides a mock function with given fields:

func (*MockKafkaReader) CommitMessages

func (_m *MockKafkaReader) CommitMessages(ctx context.Context, msgs ...kafka.Message) error

CommitMessages provides a mock function with given fields: ctx, msgs

func (*MockKafkaReader) EXPECT

func (*MockKafkaReader) FetchMessage

func (_m *MockKafkaReader) FetchMessage(ctx context.Context) (kafka.Message, error)

FetchMessage provides a mock function with given fields: ctx

func (*MockKafkaReader) ReadLastOffset

func (_m *MockKafkaReader) ReadLastOffset(ctx context.Context) (int64, error)

ReadLastOffset provides a mock function with given fields: ctx

func (*MockKafkaReader) SetOffset

func (_m *MockKafkaReader) SetOffset(offset int64) error

SetOffset provides a mock function with given fields: offset

type MockKafkaReader_Close_Call

type MockKafkaReader_Close_Call struct {
	*mock.Call
}

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

func (*MockKafkaReader_Close_Call) Return

func (*MockKafkaReader_Close_Call) Run

func (*MockKafkaReader_Close_Call) RunAndReturn

func (_c *MockKafkaReader_Close_Call) RunAndReturn(run func() error) *MockKafkaReader_Close_Call

type MockKafkaReader_CommitMessages_Call

type MockKafkaReader_CommitMessages_Call struct {
	*mock.Call
}

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

func (*MockKafkaReader_CommitMessages_Call) Return

func (*MockKafkaReader_CommitMessages_Call) Run

func (*MockKafkaReader_CommitMessages_Call) RunAndReturn

type MockKafkaReader_Expecter

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

func (*MockKafkaReader_Expecter) Close

Close is a helper method to define mock.On call

func (*MockKafkaReader_Expecter) CommitMessages

func (_e *MockKafkaReader_Expecter) CommitMessages(ctx interface{}, msgs ...interface{}) *MockKafkaReader_CommitMessages_Call

CommitMessages is a helper method to define mock.On call

  • ctx context.Context
  • msgs ...kafka.Message

func (*MockKafkaReader_Expecter) FetchMessage

func (_e *MockKafkaReader_Expecter) FetchMessage(ctx interface{}) *MockKafkaReader_FetchMessage_Call

FetchMessage is a helper method to define mock.On call

  • ctx context.Context

func (*MockKafkaReader_Expecter) ReadLastOffset

func (_e *MockKafkaReader_Expecter) ReadLastOffset(ctx interface{}) *MockKafkaReader_ReadLastOffset_Call

ReadLastOffset is a helper method to define mock.On call

  • ctx context.Context

func (*MockKafkaReader_Expecter) SetOffset

func (_e *MockKafkaReader_Expecter) SetOffset(offset interface{}) *MockKafkaReader_SetOffset_Call

SetOffset is a helper method to define mock.On call

  • offset int64

type MockKafkaReader_FetchMessage_Call

type MockKafkaReader_FetchMessage_Call struct {
	*mock.Call
}

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

func (*MockKafkaReader_FetchMessage_Call) Return

func (*MockKafkaReader_FetchMessage_Call) Run

func (*MockKafkaReader_FetchMessage_Call) RunAndReturn

type MockKafkaReader_ReadLastOffset_Call

type MockKafkaReader_ReadLastOffset_Call struct {
	*mock.Call
}

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

func (*MockKafkaReader_ReadLastOffset_Call) Return

func (*MockKafkaReader_ReadLastOffset_Call) Run

func (*MockKafkaReader_ReadLastOffset_Call) RunAndReturn

type MockKafkaReader_SetOffset_Call

type MockKafkaReader_SetOffset_Call struct {
	*mock.Call
}

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

func (*MockKafkaReader_SetOffset_Call) Return

func (*MockKafkaReader_SetOffset_Call) Run

func (*MockKafkaReader_SetOffset_Call) RunAndReturn

type MockKafkaWriter

type MockKafkaWriter struct {
	mock.Mock
}

MockKafkaWriter is an autogenerated mock type for the mockKafkaWriter type

func NewMockKafkaWriter

func NewMockKafkaWriter(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockKafkaWriter

NewMockKafkaWriter creates a new instance of MockKafkaWriter. 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 (*MockKafkaWriter) Close

func (_m *MockKafkaWriter) Close() error

Close provides a mock function with given fields:

func (*MockKafkaWriter) EXPECT

func (*MockKafkaWriter) WriteMessages

func (_m *MockKafkaWriter) WriteMessages(ctx context.Context, msgs ...kafka.Message) error

WriteMessages provides a mock function with given fields: ctx, msgs

type MockKafkaWriter_Close_Call

type MockKafkaWriter_Close_Call struct {
	*mock.Call
}

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

func (*MockKafkaWriter_Close_Call) Return

func (*MockKafkaWriter_Close_Call) Run

func (*MockKafkaWriter_Close_Call) RunAndReturn

func (_c *MockKafkaWriter_Close_Call) RunAndReturn(run func() error) *MockKafkaWriter_Close_Call

type MockKafkaWriter_Expecter

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

func (*MockKafkaWriter_Expecter) Close

Close is a helper method to define mock.On call

func (*MockKafkaWriter_Expecter) WriteMessages

func (_e *MockKafkaWriter_Expecter) WriteMessages(ctx interface{}, msgs ...interface{}) *MockKafkaWriter_WriteMessages_Call

WriteMessages is a helper method to define mock.On call

  • ctx context.Context
  • msgs ...kafka.Message

type MockKafkaWriter_WriteMessages_Call

type MockKafkaWriter_WriteMessages_Call struct {
	*mock.Call
}

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

func (*MockKafkaWriter_WriteMessages_Call) Return

func (*MockKafkaWriter_WriteMessages_Call) Run

func (*MockKafkaWriter_WriteMessages_Call) RunAndReturn

type MockNow

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

func NewMockNow

func NewMockNow() *MockNow

func (*MockNow) Now

func (m *MockNow) Now() time.Time

func (*MockNow) SetValue

func (m *MockNow) SetValue(t time.Time)

type ShutdownHooks

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

func NewShutdownHooks

func NewShutdownHooks(deps ShutdownHooksRegistryDeps) *ShutdownHooks

func NewTestShutdownHooks

func NewTestShutdownHooks() *ShutdownHooks

func (*ShutdownHooks) HasHook

func (h *ShutdownHooks) HasHook(name string, method any) bool

HasHook checks if a shutdown hook with the given name is registered. Typical usage is in tests and must be carefully considered for production scenarios.

func (*ShutdownHooks) PerformShutdown

func (h *ShutdownHooks) PerformShutdown(ctx context.Context) error

func (*ShutdownHooks) Register

func (h *ShutdownHooks) Register(name string, shutdown func(ctx context.Context) error)

func (*ShutdownHooks) RegisterNoCtx

func (h *ShutdownHooks) RegisterNoCtx(name string, shutdown func() error)

type ShutdownHooksRegistryDeps

type ShutdownHooksRegistryDeps struct {
	dig.In

	RootLogger *slog.Logger

	// config
	GracefulShutdownTimeout time.Duration `name:"config.gracefulShutdownTimeout"`
}

type TimeProvider

type TimeProvider interface {
	Now() time.Time
}

func NewTimeProvider

func NewTimeProvider() TimeProvider

type UUIDGenerator

type UUIDGenerator func() string

func NewUUIDGenerator

func NewUUIDGenerator() UUIDGenerator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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