~f4814n/frost

frost/component/sync/sync.go -rw-r--r-- 562 bytes
ff15c3c0Fabian Geiselhart Add screenshots 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package sync

import (
	"context"

	"git.sr.ht/~f4814n/frost"
	"git.sr.ht/~f4814n/matrix"
	"go.uber.org/zap"
)

type component struct {
	cli    *matrix.Client
	logger *zap.Logger
}

func New(cli *matrix.Client, logger *zap.Logger) frost.Component {
	return component{
		cli:    cli,
		logger: logger,
	}
}

func (c component) Run(rx, tx chan frost.Event) {
	go c.cli.Sync(context.TODO(), &matrix.SyncOpts{
		OnError: func(err error) error {
			c.logger.Warn("Sync error", zap.Error(err))
			return nil
		},
		Timeout: 10000,
	})
}

func (c component) Stop() {
}