Documentation ¶
Index ¶
- Constants
- type Config
- type DBServiceItemV1
- type NetMapping
- type SearchResultV1
- type ServiceCtrl
- func (ctrl *ServiceCtrl) Delete(ctx context.Context, serviceKey string, zone string) error
- func (ctrl *ServiceCtrl) PlugAll(ctx context.Context, ttl time.Duration, leaseID clientv3.LeaseID, ...) (clientv3.LeaseID, error)
- func (ctrl *ServiceCtrl) PlugAllBack(ctx context.Context, ttl time.Duration, leaseID clientv3.LeaseID, ...) (clientv3.LeaseID, error)
- func (ctrl *ServiceCtrl) Query(ctx context.Context, clientIP net.IP, service string, proto bool) (*ServiceV1, int64, error)
- func (ctrl *ServiceCtrl) QueryServiceZone(ctx context.Context, clientIP net.IP, service string, zone string, proto bool) (*ServiceV1, int64, error)
- func (ctrl *ServiceCtrl) QueryZones(ctx context.Context, clientIP net.IP, service string) (*ServiceWithRawZone, int64, error)
- func (ctrl *ServiceCtrl) SearchByServiceZone(service, zone string) (*ServiceDescV1, error)
- func (ctrl *ServiceCtrl) SearchOnlyBymd5s(md5s []string) ([]ServiceDescV1, error)
- func (ctrl *ServiceCtrl) SearchService(service string, skip int64, limit int64) (*SearchResultV1, error)
- func (ctrl *ServiceCtrl) Unplug(ctx context.Context, service, zone, addr string) error
- func (ctrl *ServiceCtrl) Watch(ctx context.Context, clientIP net.IP, serviceKey string, revision int64, ...) (*ServiceV1, int64, error)
- func (ctrl *ServiceCtrl) WatchServiceDesc(ctx context.Context, zone string, revision int64) (*ServiceDescWatchResult, error)
- func (ctrl *ServiceCtrl) WatchServiceDescBack(ctx context.Context, zone string, revision int64) (*ServiceDescWatchResult, error)
- type ServiceDescEvent
- type ServiceDescV1
- type ServiceDescWatchResult
- type ServiceEndpoint
- type ServiceItemV1
- type ServiceV1
- type ServiceWithRawZone
- type ServiceZoneV1
Constants ¶
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 ¶
NewServiceCtrl new service ctrl
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 ¶
ServiceWithRawZone service with raw zone
type ServiceZoneV1 ¶
type ServiceZoneV1 struct { Endpoints []ServiceEndpoint `json:"endpoints"` ServiceDescV1 }
ServiceZoneV1 service zone