Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
12c700a5c5 | |||
db413ce145 | |||
12e379ab62 |
@ -8,15 +8,18 @@ import (
|
||||
"git.tordarus.net/tordarus/omada-api/model"
|
||||
)
|
||||
|
||||
func (api *Api) GetClients(siteID model.SiteID) <-chan *model.Client {
|
||||
func (api *Api) GetClients(siteID model.SiteID) (<-chan *model.Client, <-chan error) {
|
||||
out := make(chan *model.Client, 1000)
|
||||
errChan := make(chan error)
|
||||
|
||||
go func() {
|
||||
defer close(out)
|
||||
defer close(errChan)
|
||||
|
||||
for page := 1; ; page++ {
|
||||
resp, err := api.getClients(page, siteID)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,7 +33,7 @@ func (api *Api) GetClients(siteID model.SiteID) <-chan *model.Client {
|
||||
}
|
||||
}()
|
||||
|
||||
return out
|
||||
return out, errChan
|
||||
}
|
||||
|
||||
func (api *Api) getClients(page int, siteID model.SiteID) (*model.PagedResponse[model.Client], error) {
|
||||
|
@ -8,15 +8,18 @@ import (
|
||||
"git.tordarus.net/tordarus/omada-api/model"
|
||||
)
|
||||
|
||||
func (api *Api) GetDevices(siteID model.SiteID) <-chan *model.Device {
|
||||
func (api *Api) GetDevices(siteID model.SiteID) (<-chan *model.Device, <-chan error) {
|
||||
out := make(chan *model.Device, 1000)
|
||||
errChan := make(chan error)
|
||||
|
||||
go func() {
|
||||
defer close(out)
|
||||
defer close(errChan)
|
||||
|
||||
for page := 1; ; page++ {
|
||||
resp, err := api.getDevices(page, siteID)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,7 +33,7 @@ func (api *Api) GetDevices(siteID model.SiteID) <-chan *model.Device {
|
||||
}
|
||||
}()
|
||||
|
||||
return out
|
||||
return out, errChan
|
||||
}
|
||||
|
||||
func (api *Api) getDevices(page int, siteID model.SiteID) (*model.PagedResponse[model.Device], error) {
|
||||
|
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module git.tordarus.net/tordarus/omada-api
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require git.tordarus.net/tordarus/ezhttp v0.0.4
|
||||
require git.tordarus.net/tordarus/ezhttp v0.0.5
|
||||
|
4
go.sum
4
go.sum
@ -1,2 +1,2 @@
|
||||
git.tordarus.net/tordarus/ezhttp v0.0.4 h1:wm7rhol9MHZTZXOzH5I6Q4idjCiFfA4XwAMISZhTcCs=
|
||||
git.tordarus.net/tordarus/ezhttp v0.0.4/go.mod h1:Zq9o0Hibny61GqSCwJHa0PfGjVoUFv/zt2PjiQHXvmY=
|
||||
git.tordarus.net/tordarus/ezhttp v0.0.5 h1:pxfEdfDeOHT/ATXYy5OQHmeBIho121SBuFvU4ISQ7w0=
|
||||
git.tordarus.net/tordarus/ezhttp v0.0.5/go.mod h1:Zq9o0Hibny61GqSCwJHa0PfGjVoUFv/zt2PjiQHXvmY=
|
||||
|
7
site.go
7
site.go
@ -8,15 +8,18 @@ import (
|
||||
"git.tordarus.net/tordarus/omada-api/model"
|
||||
)
|
||||
|
||||
func (api *Api) GetSites() <-chan *model.Site {
|
||||
func (api *Api) GetSites() (<-chan *model.Site, <-chan error) {
|
||||
out := make(chan *model.Site, 1000)
|
||||
errChan := make(chan error)
|
||||
|
||||
go func() {
|
||||
defer close(out)
|
||||
defer close(errChan)
|
||||
|
||||
for page := 1; ; page++ {
|
||||
resp, err := api.getSites(page)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,7 +33,7 @@ func (api *Api) GetSites() <-chan *model.Site {
|
||||
}
|
||||
}()
|
||||
|
||||
return out
|
||||
return out, errChan
|
||||
}
|
||||
|
||||
func (api *Api) getSites(page int) (*model.PagedResponse[model.Site], error) {
|
||||
|
Reference in New Issue
Block a user