service

package
v0.0.0-...-d28c369 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAddr      = errors.New("no IP address provided")
	ErrNoName      = errors.New("no domain name provided")
	ErrNoType      = errors.New("no DNS record type provided")
	ErrEmtpyRecord = errors.New("record cannot be empty")
)

Functions

This section is empty.

Types

type Answering

type Answering interface {
	GetRecordByTypeAndDomain(context.Context, string, string) (*store.Record, error)
	AnswerDNS(context.Context, *store.Record, *dnsr.Msg)
}

Answering interface joins the needed store.Repository-derived method with the dns.Repository one for answering DNS queries. This is done to provide more

granular scope of which operations can a certain module access

type DNSService

type DNSService interface {
	// AnswerDNS uses the dns.Repository to reply to the dns.Msg `m` with the answer
	// in store.Record `r`
	AnswerDNS(ctx context.Context, r *store.Record, m *dnsr.Msg)
}

DNSService interface joins the set of methods leveraging the dns.Repository

type HealthService

type HealthService interface {
	// StoreHealth uses the health.Repository to generate a health.StoreReport
	StoreHealth(ctx context.Context) *health.StoreReport
	// DNSHealth uses the health.Repository to generate a health.DNSReport
	DNSHealth(ctx context.Context) *health.DNSReport
	// HTTPHealth uses the health.Repository to generate a health.HTTPReport
	HTTPHealth(ctx context.Context) *health.HTTPReport
	// Health uses the health.Repository to generate a health.Report
	Health(ctx context.Context) *health.Report
}

HealthService interface joins the set of methods leveraging the health.Repository

type Service

type Service interface {
	StoreService
	DNSService
	HealthService
}

Service interface packs the different sets of operations supported by this DNS service.

While the repositories the service contains will work independently one from the other, the Service interface is there to *glue them* together and to allow inter-repository operations. It is one level below the transport layer.

func New

func New(
	dnsR dns.Repository,
	storeR store.Repository,
	healthR health.Repository,
	conf *config.Config,
) Service

New will create a Service based on the input dns.Repository, store.Repository, health.Repository and configuration. These elements are required in order to initialize the Service with all elements and settings needed (such as HTTP port / UDP address)

func WithLogger

func WithLogger(s Service, logger logx.Logger) Service

WithLogger wraps the input Service `s` with the input logx.Logger `logger`

func WithTrace

func WithTrace(s Service) Service

WithTrace wraps the input Service `s` with tracing instrumentation

type StoreService

type StoreService interface {
	// AddRecord uses the store.Repository to create a DNS Record
	AddRecord(ctx context.Context, r *store.Record) error
	// AddRecords uses the store.Repository to create a set of DNS Records
	AddRecords(ctx context.Context, rs ...*store.Record) error
	// ListRecord uses the store.Repository to return all DNS Records
	ListRecords(ctx context.Context) ([]*store.Record, error)
	// GetRecordByDomain uses the store.Repository to return the DNS Record associated with
	// the domain name and record type found in store.Record `r`
	GetRecordByTypeAndDomain(ctx context.Context, rtype, domain string) (*store.Record, error)
	// GetRecordByDomain uses the store.Repository to return the DNS Records associated with
	// the IP address found in store.Record `r`
	GetRecordByAddress(ctx context.Context, address string) ([]*store.Record, error)
	// UpdateRecord uses the store.Repository to update the record with domain name `domain`,
	// based on the data provided in store.Record `r`
	UpdateRecord(ctx context.Context, domain string, r *store.Record) error
	// DeleteRecord uses the store.Repository to remove the store.Record based on input `r`
	DeleteRecord(ctx context.Context, r *store.Record) error
}

StoreService interface joins the set of methods leveraging the store.Repository

type StoreWithHealth

type StoreWithHealth interface {
	StoreService
	HealthService
}

StoreService interface joins the store.Repository-derived methods with the health.Repository ones. This is done to provide more granular scope of which operations can a certain module access

Jump to

Keyboard shortcuts

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