WIP pubsub and sync logic
This commit is contained in:
parent
bc1a0cf678
commit
1ee6a4c7cb
13
service/sync/pubsub.go
Normal file
13
service/sync/pubsub.go
Normal file
@ -0,0 +1,13 @@
|
||||
package sync
|
||||
|
||||
type PubSubPayload struct {
|
||||
}
|
||||
|
||||
type PubSub interface {
|
||||
Send(msg *PubSubPayload) error
|
||||
Listen(chan *PubSubPayload) error
|
||||
}
|
||||
|
||||
func NewPubSub(topic string) PubSub {
|
||||
return nil
|
||||
}
|
||||
44
service/sync/service.go
Normal file
44
service/sync/service.go
Normal file
@ -0,0 +1,44 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
|
||||
)
|
||||
|
||||
type service struct {
|
||||
pubSub PubSub
|
||||
}
|
||||
|
||||
const CName = "SyncService"
|
||||
|
||||
func (s *service) Init(ctx context.Context, a *app.App) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Name() (name string) {
|
||||
return CName
|
||||
}
|
||||
|
||||
func (s *service) Run(ctx context.Context) (err error) {
|
||||
ch := make(chan *PubSubPayload)
|
||||
err = s.pubSub.Listen(ch)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Close(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) listen(ctx context.Context, ch chan *PubSubPayload) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case payload := <-ch:
|
||||
// TODO: get object from object service and try to perform sync
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user