Skip to content

Commit

Permalink
rename ip observer to be a service
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlatsch committed Oct 4, 2024
1 parent d76199e commit 0e5ab92
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/service/godaddy_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type GodaddyService struct {
Config *models.Config
GodaddyApi api.GodaddyApi
IpApi api.IpApi
IpObserver IpObserver
IpObserver IpObserverService
}

func (self *GodaddyService) PrintDomainDetail() error {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/gogaddy_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestPrintDomainDetails(t *testing.T) {
godaddyApiFake := api.GodaddyApiFake{}
ipOpserver := service.IpObserver{}
ipOpserver := service.IpObserverService{}

service := service.GodaddyService{
Config: &models.Config{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/leonlatsch/go-resolve/internal/models"
)

type IpObserver struct {
type IpObserverService struct {
IpApi api.IpApi
Config *models.Config
LastIp string
}

func (self *IpObserver) ObserveIp(callback func(ip string)) {
func (self *IpObserverService) ObserveIp(callback func(ip string)) {
ipChan := self.observePublicIp()

for {
Expand All @@ -24,7 +24,7 @@ func (self *IpObserver) ObserveIp(callback func(ip string)) {
}
}

func (self *IpObserver) observePublicIp() chan string {
func (self *IpObserverService) observePublicIp() chan string {
ipChan := make(chan string)
interval, err := time.ParseDuration(self.Config.Interval)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/update_url_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type UpdateUrlService struct {
Config *models.Config
UpdateUrlApi api.UpdateUrlApi
IpObserver IpObserver
IpObserver IpObserverService
}

func (self *UpdateUrlService) ObserveAndUpdateDns() {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func createService(conf *models.Config, httpClient http.HttpClient) (service.Dns
updateUrlService := service.UpdateUrlService{
Config: conf,
UpdateUrlApi: &api.UpdateUrlApiImpl{Config: conf, HttpClient: httpClient},
IpObserver: service.IpObserver{
IpObserver: service.IpObserverService{
IpApi: &api.IpApiImpl{HttpClient: httpClient},
Config: conf,
},
Expand All @@ -48,7 +48,7 @@ func createService(conf *models.Config, httpClient http.HttpClient) (service.Dns
godaddyService := service.GodaddyService{
Config: conf,
GodaddyApi: &api.GodaddyApiImpl{Config: conf, HttpClient: httpClient},
IpObserver: service.IpObserver{
IpObserver: service.IpObserverService{
IpApi: &api.IpApiImpl{HttpClient: httpClient},
Config: conf,
},
Expand Down

0 comments on commit 0e5ab92

Please sign in to comment.