services

package
v0.0.0-...-df8b58b Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultZone = "default"

DefaultZone default service zone

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	KeyPrefix               string       `default:"/services" yaml:"key_prefix"`
	NetMappings             []NetMapping `yaml:"net_mappings"`
	BannedEndpointAddresses []string     `yaml:"banned_endpoint_addresses"`
	// contains filtered or unexported fields
}

Config service module config

type DBServiceItemV1

type DBServiceItemV1 struct {
	ID          int64     `json:"id"`
	Status      int       `json:"-"`
	Service     string    `json:"service"`
	Zone        string    `json:"zone"`
	Type        string    `json:"type"`
	Proto       string    `json:"proto"`
	Description string    `json:"description"`
	CreateTime  time.Time `json:"create_time"`
	ModifyTime  time.Time `json:"modify_time"`
	Md5         string    `json:"proto_md5"`
	Md5Status   int       `json:"md5_status"`
}

DBServiceItemV1 service table

type NetMapping

type NetMapping struct {
	SrcNet string `yaml:"src_net"`
	DestIP string `yaml:"dest_ip"`
	// contains filtered or unexported fields
}

NetMapping net mapping

type SearchResultV1

type SearchResultV1 struct {
	Services []ServiceItemV1 `json:"services"`
	Total    int64           `json:"total"`
}

SearchResultV1 search result

type ServiceCtrl

type ServiceCtrl struct {
	ProtoSwitch bool
	// contains filtered or unexported fields
}

ServiceCtrl service module controller

func NewServiceCtrl

func NewServiceCtrl(config *Config, db *sql.DB, etcdClient *clientv3.Client) (*ServiceCtrl, error)

NewServiceCtrl new service ctrl

func (*ServiceCtrl) Delete

func (ctrl *ServiceCtrl) Delete(ctx context.Context, serviceKey string, zone string) error

Delete delete service

func (*ServiceCtrl) PlugAll

func (ctrl *ServiceCtrl) PlugAll(ctx context.Context,
	ttl time.Duration, leaseID clientv3.LeaseID,
	descs []ServiceDescV1, endpoint *ServiceEndpoint) (clientv3.LeaseID, error)

PlugAll plug services

func (*ServiceCtrl) PlugAllBack

func (ctrl *ServiceCtrl) PlugAllBack(ctx context.Context,
	ttl time.Duration, leaseID clientv3.LeaseID,
	descs []ServiceDescV1, endpoint *ServiceEndpoint) (clientv3.LeaseID, error)

PlugAll plug services

func (*ServiceCtrl) Query

func (ctrl *ServiceCtrl) Query(ctx context.Context, clientIP net.IP, service string, proto bool) (*ServiceV1, int64, error)

Query query service

func (*ServiceCtrl) QueryServiceZone

func (ctrl *ServiceCtrl) QueryServiceZone(ctx context.Context, clientIP net.IP, service string, zone string, proto bool) (*ServiceV1, int64, error)

QueryServiceZone query service zone with service key and zone

func (*ServiceCtrl) QueryZones

func (ctrl *ServiceCtrl) QueryZones(ctx context.Context, clientIP net.IP, service string) (*ServiceWithRawZone, int64, error)

QueryZones query services with raw zone

func (*ServiceCtrl) SearchByServiceZone

func (ctrl *ServiceCtrl) SearchByServiceZone(service, zone string) (*ServiceDescV1, error)

SearchByServiceZone search ServiceDescV1 via db

func (*ServiceCtrl) SearchOnlyBymd5s

func (ctrl *ServiceCtrl) SearchOnlyBymd5s(md5s []string) ([]ServiceDescV1, error)

SearchOnlyBymd5s search ServiceDescV1 via db

func (*ServiceCtrl) SearchService

func (ctrl *ServiceCtrl) SearchService(service string, skip int64, limit int64) (*SearchResultV1, error)

SearchService search service via db

func (*ServiceCtrl) Unplug

func (ctrl *ServiceCtrl) Unplug(ctx context.Context, service, zone, addr string) error

Unplug unplug service

func (*ServiceCtrl) Watch

func (ctrl *ServiceCtrl) Watch(ctx context.Context, clientIP net.IP, serviceKey string, revision int64, proto bool) (*ServiceV1, int64, error)

Watch watch service

func (*ServiceCtrl) WatchServiceDesc

func (ctrl *ServiceCtrl) WatchServiceDesc(ctx context.Context, zone string, revision int64) (*ServiceDescWatchResult, error)

WatchServiceDesc watch service desc

func (*ServiceCtrl) WatchServiceDescBack

func (ctrl *ServiceCtrl) WatchServiceDescBack(ctx context.Context, zone string, revision int64) (*ServiceDescWatchResult, error)

WatchServiceDesc watch service desc

type ServiceDescEvent

type ServiceDescEvent struct {
	EventType string        `json:"event_type"`
	Service   ServiceDescV1 `json:"service"`
}

ServiceDescEvent desc event

type ServiceDescV1

type ServiceDescV1 struct {
	Service     string `json:"service"`
	Zone        string `json:"zone,omitempty"`
	Type        string `json:"type,omitempty"`
	Proto       string `json:"proto,omitempty"`
	Description string `json:"description,omitempty"`
	Md5         string `json:"-"`
}

ServiceDescV1 service descriptor

func (*ServiceDescV1) Marshal

func (desc *ServiceDescV1) Marshal() ([]byte, error)

Marshal marshal impl

type ServiceDescWatchResult

type ServiceDescWatchResult struct {
	Events   []ServiceDescEvent `json:"events"`
	Revision int64              `json:"revision"`
}

ServiceDescWatchResult desc watch result

type ServiceEndpoint

type ServiceEndpoint struct {
	Address string `json:"address"`
	Config  string `json:"config,omitempty"`
}

ServiceEndpoint service endpoint

func (*ServiceEndpoint) Marshal

func (endpoint *ServiceEndpoint) Marshal() ([]byte, error)

Marshal marshal impl

type ServiceItemV1

type ServiceItemV1 struct {
	Service string `json:"service"`
	Zone    string `json:"zone"`
	Type    string `json:"type"`
}

ServiceItemV1 service item v1

type ServiceV1

type ServiceV1 struct {
	Service string                    `json:"service"`
	Zones   map[string]*ServiceZoneV1 `json:"zones"`
}

ServiceV1 service

type ServiceWithRawZone

type ServiceWithRawZone struct {
	Service string   `json:"service"`
	Zones   []string `json:"zones"`
}

ServiceWithRawZone service with raw zone

type ServiceZoneV1

type ServiceZoneV1 struct {
	Endpoints []ServiceEndpoint `json:"endpoints"`

	ServiceDescV1
}

ServiceZoneV1 service zone

Jump to

Keyboard shortcuts

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