mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
refactor(provider): rename route/provider/types to provider
This commit is contained in:
parent
26bea0d21d
commit
3689e72eff
4 changed files with 19 additions and 19 deletions
|
@ -3,7 +3,7 @@ package provider
|
||||||
import (
|
import (
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/route"
|
"github.com/yusing/go-proxy/internal/route"
|
||||||
"github.com/yusing/go-proxy/internal/route/provider/types"
|
provider "github.com/yusing/go-proxy/internal/route/provider/types"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
"github.com/yusing/go-proxy/internal/watcher"
|
"github.com/yusing/go-proxy/internal/watcher"
|
||||||
eventsPkg "github.com/yusing/go-proxy/internal/watcher/events"
|
eventsPkg "github.com/yusing/go-proxy/internal/watcher/events"
|
||||||
|
@ -74,10 +74,10 @@ func (handler *EventHandler) matchAny(events []watcher.Event, route *route.Route
|
||||||
|
|
||||||
func (handler *EventHandler) match(event watcher.Event, route *route.Route) bool {
|
func (handler *EventHandler) match(event watcher.Event, route *route.Route) bool {
|
||||||
switch handler.provider.Type() {
|
switch handler.provider.Type() {
|
||||||
case types.ProviderTypeDocker, types.ProviderTypeAgent:
|
case provider.TypeDocker, provider.TypeAgent:
|
||||||
return route.Container.ContainerID == event.ActorID ||
|
return route.Container.ContainerID == event.ActorID ||
|
||||||
route.Container.ContainerName == event.ActorName
|
route.Container.ContainerName == event.ActorName
|
||||||
case types.ProviderTypeFile:
|
case provider.TypeFile:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// should never happen
|
// should never happen
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/yusing/go-proxy/agent/pkg/agent"
|
"github.com/yusing/go-proxy/agent/pkg/agent"
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/route"
|
"github.com/yusing/go-proxy/internal/route"
|
||||||
"github.com/yusing/go-proxy/internal/route/provider/types"
|
provider "github.com/yusing/go-proxy/internal/route/provider/types"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
W "github.com/yusing/go-proxy/internal/watcher"
|
W "github.com/yusing/go-proxy/internal/watcher"
|
||||||
"github.com/yusing/go-proxy/internal/watcher/events"
|
"github.com/yusing/go-proxy/internal/watcher/events"
|
||||||
|
@ -19,7 +19,7 @@ type (
|
||||||
Provider struct {
|
Provider struct {
|
||||||
ProviderImpl
|
ProviderImpl
|
||||||
|
|
||||||
t types.ProviderType
|
t provider.Type
|
||||||
routes route.Routes
|
routes route.Routes
|
||||||
}
|
}
|
||||||
ProviderImpl interface {
|
ProviderImpl interface {
|
||||||
|
@ -40,21 +40,21 @@ var ErrEmptyProviderName = errors.New("empty provider name")
|
||||||
|
|
||||||
func NewFileProvider(filename string) *Provider {
|
func NewFileProvider(filename string) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
t: types.ProviderTypeFile,
|
t: provider.TypeFile,
|
||||||
ProviderImpl: FileProviderImpl(filename),
|
ProviderImpl: FileProviderImpl(filename),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDockerProvider(name string, dockerHost string) *Provider {
|
func NewDockerProvider(name string, dockerHost string) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
t: types.ProviderTypeDocker,
|
t: provider.TypeDocker,
|
||||||
ProviderImpl: DockerProviderImpl(name, dockerHost),
|
ProviderImpl: DockerProviderImpl(name, dockerHost),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAgentProvider(cfg *agent.AgentConfig) *Provider {
|
func NewAgentProvider(cfg *agent.AgentConfig) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
t: types.ProviderTypeAgent,
|
t: provider.TypeAgent,
|
||||||
ProviderImpl: &AgentProvider{
|
ProviderImpl: &AgentProvider{
|
||||||
AgentConfig: cfg,
|
AgentConfig: cfg,
|
||||||
docker: DockerProviderImpl(cfg.Name(), cfg.FakeDockerHost()),
|
docker: DockerProviderImpl(cfg.Name(), cfg.FakeDockerHost()),
|
||||||
|
@ -62,7 +62,7 @@ func NewAgentProvider(cfg *agent.AgentConfig) *Provider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Type() types.ProviderType {
|
func (p *Provider) Type() provider.Type {
|
||||||
return p.t
|
return p.t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
R "github.com/yusing/go-proxy/internal/route"
|
R "github.com/yusing/go-proxy/internal/route"
|
||||||
"github.com/yusing/go-proxy/internal/route/provider/types"
|
provider "github.com/yusing/go-proxy/internal/route/provider/types"
|
||||||
route "github.com/yusing/go-proxy/internal/route/types"
|
route "github.com/yusing/go-proxy/internal/route/types"
|
||||||
"github.com/yusing/go-proxy/internal/watcher/health"
|
"github.com/yusing/go-proxy/internal/watcher/health"
|
||||||
)
|
)
|
||||||
|
@ -17,10 +17,10 @@ type (
|
||||||
NumUnknown uint16 `json:"unknown"`
|
NumUnknown uint16 `json:"unknown"`
|
||||||
}
|
}
|
||||||
ProviderStats struct {
|
ProviderStats struct {
|
||||||
Total uint16 `json:"total"`
|
Total uint16 `json:"total"`
|
||||||
RPs RouteStats `json:"reverse_proxies"`
|
RPs RouteStats `json:"reverse_proxies"`
|
||||||
Streams RouteStats `json:"streams"`
|
Streams RouteStats `json:"streams"`
|
||||||
Type types.ProviderType `json:"type"`
|
Type provider.Type `json:"type"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package types
|
package provider
|
||||||
|
|
||||||
type ProviderType string
|
type Type string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProviderTypeDocker ProviderType = "docker"
|
TypeDocker Type = "docker"
|
||||||
ProviderTypeFile ProviderType = "file"
|
TypeFile Type = "file"
|
||||||
ProviderTypeAgent ProviderType = "agent"
|
TypeAgent Type = "agent"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue