ecs

package
v0.0.66 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ecs is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHosts

func GetHosts()

Types

type IToolsECS

type IToolsECS interface {
	GetTaskECSHosts(ctx context.Context, ctxLogger *builder.Context) ([]string, error)
}

IToolsECS describes the ECS host discovery operations that can be consumed or mocked by other components.

func New

func New(mock IToolsECS) IToolsECS

New creates a new ECS tool instance. When a mock is provided, all calls are delegated to it.

type MockIToolsECS

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

MockIToolsECS is a mock of IToolsECS interface.

func NewMockIToolsECS

func NewMockIToolsECS(ctrl *gomock.Controller) *MockIToolsECS

NewMockIToolsECS creates a new mock instance.

func (*MockIToolsECS) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIToolsECS) GetTaskECSHosts

func (m *MockIToolsECS) GetTaskECSHosts(ctx context.Context, ctxLogger *builder.Context) ([]string, error)

GetTaskECSHosts mocks base method.

type MockIToolsECSMockRecorder

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

MockIToolsECSMockRecorder is the mock recorder for MockIToolsECS.

func (*MockIToolsECSMockRecorder) GetTaskECSHosts

func (mr *MockIToolsECSMockRecorder) GetTaskECSHosts(ctx, ctxLogger interface{}) *gomock.Call

GetTaskECSHosts indicates an expected call of GetTaskECSHosts.

type MockecsAPI

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

MockecsAPI is a mock of ecsAPI interface.

func NewMockecsAPI

func NewMockecsAPI(ctrl *gomock.Controller) *MockecsAPI

NewMockecsAPI creates a new mock instance.

func (*MockecsAPI) DescribeTasks

func (m *MockecsAPI) DescribeTasks(ctx context.Context, params *ecs.DescribeTasksInput, optFns ...func(*ecs.Options)) (*ecs.DescribeTasksOutput, error)

DescribeTasks mocks base method.

func (*MockecsAPI) EXPECT

func (m *MockecsAPI) EXPECT() *MockecsAPIMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockecsAPI) ListClusters

func (m *MockecsAPI) ListClusters(ctx context.Context, params *ecs.ListClustersInput, optFns ...func(*ecs.Options)) (*ecs.ListClustersOutput, error)

ListClusters mocks base method.

func (*MockecsAPI) ListTasks

func (m *MockecsAPI) ListTasks(ctx context.Context, params *ecs.ListTasksInput, optFns ...func(*ecs.Options)) (*ecs.ListTasksOutput, error)

ListTasks mocks base method.

type MockecsAPIMockRecorder

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

MockecsAPIMockRecorder is the mock recorder for MockecsAPI.

func (*MockecsAPIMockRecorder) DescribeTasks

func (mr *MockecsAPIMockRecorder) DescribeTasks(ctx, params interface{}, optFns ...interface{}) *gomock.Call

DescribeTasks indicates an expected call of DescribeTasks.

func (*MockecsAPIMockRecorder) ListClusters

func (mr *MockecsAPIMockRecorder) ListClusters(ctx, params interface{}, optFns ...interface{}) *gomock.Call

ListClusters indicates an expected call of ListClusters.

func (*MockecsAPIMockRecorder) ListTasks

func (mr *MockecsAPIMockRecorder) ListTasks(ctx, params interface{}, optFns ...interface{}) *gomock.Call

ListTasks indicates an expected call of ListTasks.

type MocklistClustersPager

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

MocklistClustersPager is a mock of listClustersPager interface.

func NewMocklistClustersPager

func NewMocklistClustersPager(ctrl *gomock.Controller) *MocklistClustersPager

NewMocklistClustersPager creates a new mock instance.

func (*MocklistClustersPager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MocklistClustersPager) HasMorePages

func (m *MocklistClustersPager) HasMorePages() bool

HasMorePages mocks base method.

func (*MocklistClustersPager) NextPage

func (m *MocklistClustersPager) NextPage(ctx context.Context, optFns ...func(*ecs.Options)) (*ecs.ListClustersOutput, error)

NextPage mocks base method.

type MocklistClustersPagerMockRecorder

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

MocklistClustersPagerMockRecorder is the mock recorder for MocklistClustersPager.

func (*MocklistClustersPagerMockRecorder) HasMorePages

func (mr *MocklistClustersPagerMockRecorder) HasMorePages() *gomock.Call

HasMorePages indicates an expected call of HasMorePages.

func (*MocklistClustersPagerMockRecorder) NextPage

func (mr *MocklistClustersPagerMockRecorder) NextPage(ctx interface{}, optFns ...interface{}) *gomock.Call

NextPage indicates an expected call of NextPage.

type MocklistTasksPager

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

MocklistTasksPager is a mock of listTasksPager interface.

func NewMocklistTasksPager

func NewMocklistTasksPager(ctrl *gomock.Controller) *MocklistTasksPager

NewMocklistTasksPager creates a new mock instance.

func (*MocklistTasksPager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MocklistTasksPager) HasMorePages

func (m *MocklistTasksPager) HasMorePages() bool

HasMorePages mocks base method.

func (*MocklistTasksPager) NextPage

func (m *MocklistTasksPager) NextPage(ctx context.Context, optFns ...func(*ecs.Options)) (*ecs.ListTasksOutput, error)

NextPage mocks base method.

type MocklistTasksPagerMockRecorder

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

MocklistTasksPagerMockRecorder is the mock recorder for MocklistTasksPager.

func (*MocklistTasksPagerMockRecorder) HasMorePages

func (mr *MocklistTasksPagerMockRecorder) HasMorePages() *gomock.Call

HasMorePages indicates an expected call of HasMorePages.

func (*MocklistTasksPagerMockRecorder) NextPage

func (mr *MocklistTasksPagerMockRecorder) NextPage(ctx interface{}, optFns ...interface{}) *gomock.Call

NextPage indicates an expected call of NextPage.

type Target

type Target struct {
	IP      string
	IsSelf  bool
	TaskArn string
}

Target represents an ECS task that can receive a broadcast request.

type ToolsECS

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

ToolsECS resolves broadcast hosts from ECS tasks and can delegate to a mock.

func (*ToolsECS) GetTaskECSHosts

func (t *ToolsECS) GetTaskECSHosts(ctx context.Context, ctxLogger *builder.Context) (result []string, _ error)

GetTaskECSHosts returns the private IPs of peer ECS tasks that belong to the same ECS service as the current task.

Example usage with a Gin server prepared for testing:

type ECSHostDiscovery interface {
	GetTaskECSHosts(ctx context.Context, ctxLogger *builder.Context) ([]string, error)
}

type RefreshHandler struct {
	discovery ECSHostDiscovery
}

func NewRefreshHandler(discovery ECSHostDiscovery) *RefreshHandler {
	return &RefreshHandler{discovery: discovery}
}

func (h *RefreshHandler) Register(api *gin.RouterGroup) {
	api.GET("/refresh/hosts", h.GetHosts)
}

func (h *RefreshHandler) GetHosts(c *gin.Context) {
	ctx := c.Request.Context()
	ctxLogger := builder.New(ctx)

	hosts, err := h.discovery.GetTaskECSHosts(ctx, ctxLogger)
	if err != nil {
		c.JSON(500, gin.H{"error": err.Error()})
		return
	}

	serverGin.SetHostsRefresh(hosts...)
	c.JSON(200, gin.H{"hosts": hosts})
}

Production setup:

srv, err := serverGin.CreateApp()
if err != nil {
	panic(err)
}

api := serverGin.GetRoute("/api/v1")
handler := NewRefreshHandler(ecs.New(nil))
handler.Register(api)

serverGin.Start(srv)

Test setup:

type mockECSDiscovery struct{}

func (m *mockECSDiscovery) GetTaskECSHosts(_ context.Context, _ *builder.Context) ([]string, error) {
	return []string{"10.1.0.20", "10.1.0.21"}, nil
}

Jump to

Keyboard shortcuts

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