remove export publisher, pooler

This commit is contained in:
onyx-and-iris 2022-06-26 01:41:05 +01:00
parent 83dccb483b
commit 717c738583
2 changed files with 14 additions and 14 deletions

View File

@ -6,17 +6,17 @@ type observer interface {
}
// Publisher defines methods that support observers
type Publisher struct {
type publisher struct {
observerList []observer
}
// Register adds an observer to observerList
func (p *Publisher) Register(o observer) {
func (p *publisher) Register(o observer) {
p.observerList = append(p.observerList, o)
}
// Deregister removes an observer from observerList
func (p *Publisher) Deregister(o observer) {
func (p *publisher) Deregister(o observer) {
var indexToRemove int
for i, observer := range p.observerList {
@ -30,7 +30,7 @@ func (p *Publisher) Deregister(o observer) {
}
// notify updates observers of any changes
func (p *Publisher) notify(subject string) {
func (p *publisher) notify(subject string) {
for _, observer := range p.observerList {
observer.OnUpdate(subject)
}
@ -38,20 +38,20 @@ func (p *Publisher) notify(subject string) {
// Pooler continuously polls the dirty paramters
// it is expected to be run in a goroutine
type Pooler struct {
type pooler struct {
run bool
Publisher
publisher
}
func newPooler() *Pooler {
p := &Pooler{
func newPooler() *pooler {
p := &pooler{
run: true,
}
go p.runner()
return p
}
func (p *Pooler) runner() {
func (p *pooler) runner() {
for p.run {
if pdirty() {
p.notify("pdirty")

View File

@ -15,7 +15,7 @@ type remote struct {
Command *command
Vban *vban
Pooler *Pooler
pooler *pooler
}
// String implements the fmt.stringer interface
@ -26,14 +26,14 @@ func (r *remote) String() string {
// Login logs into the API
// then it intializes the pooler
func (r *remote) Login() {
r.Pooler = newPooler()
r.pooler = newPooler()
login(r.kind.name)
}
// Logout logs out of the API
// it also terminates the pooler
func (r *remote) Logout() {
r.Pooler.run = false
r.pooler.run = false
logout()
}
@ -51,12 +51,12 @@ func (r *remote) SendText(script string) {
// Register forwards the register method to Pooler
func (r *remote) Register(o observer) {
r.Pooler.Register(o)
r.pooler.Register(o)
}
// Register forwards the deregister method to Pooler
func (r *remote) Deregister(o observer) {
r.Pooler.Deregister(o)
r.pooler.Deregister(o)
}
type remoteBuilder interface {