consul

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright © 2025 Juliano Martinez <juliano@martinez.io>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetFactory

func ResetFactory()

ResetFactory resets to the default factory

func SetFactory

func SetFactory(f ClientFactory)

SetFactory allows tests to inject a mock factory

Types

type Agent

type Agent interface {
	Service(string, *api.QueryOptions) (*api.AgentService, *api.QueryMeta, error)
	ServiceRegister(*api.AgentServiceRegistration) error
}

Agent is an interface for the Consul agent.

type ApiWrapper

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

ApiWrapper wraps the Consul API client to conform to the Client interface.

func NewConsulAPIWrapper

func NewConsulAPIWrapper(client *api.Client) *ApiWrapper

NewConsulAPIWrapper creates a new instance of ApiWrapper.

func (*ApiWrapper) Agent

func (w *ApiWrapper) Agent() Agent

Agent returns an object that conforms to the Agent interface.

type Client

type Client interface {
	Agent() Agent
}

Client is an interface for the Consul client.

func CreateClient

func CreateClient(address, token string) (Client, error)

CreateClient is a convenience function that uses the global factory

type ClientFactory

type ClientFactory interface {
	NewClient(address, token string) (Client, error)
}

ClientFactory is an interface for creating Consul clients

var Factory ClientFactory = &DefaultFactory{}

Factory is the global factory instance (can be overridden for testing)

type DefaultFactory

type DefaultFactory struct{}

DefaultFactory creates real Consul clients

func (*DefaultFactory) NewClient

func (f *DefaultFactory) NewClient(address, token string) (Client, error)

NewClient creates a new Consul client with the given configuration

type MockFactory

type MockFactory struct {
	MockClient Client
	MockError  error
}

MockFactory creates mock Consul clients for testing

func (*MockFactory) NewClient

func (f *MockFactory) NewClient(address, token string) (Client, error)

NewClient returns the mock client or error

Jump to

Keyboard shortcuts

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