mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-01 19:36:32 +02:00
* refactor backend, implement encrypted store * refactor in-memory store * wip * wip * wip * add syncer test * fix redis expiry * fix linting issues * fix test by skipping non-config records * fix backoff import * fix init issues * fix query * wait for initial sync before starting directory sync * add type to SyncLatest * add more log messages, fix deadlock in in-memory store, always return server version from SyncLatest * update sync types and tests * add redis tests * skip macos in github actions * add comments to proto * split getBackend into separate methods * handle errors in initVersion * return different error for not found vs other errors in get * use exponential backoff for redis transaction retry * rename raw to result * use context instead of close channel * store type urls as constants in databroker * use timestampb instead of ptypes * fix group merging not waiting * change locked names * update GetAll to return latest record version * add method to grpcutil to get the type url for a protobuf type
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package manager
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/rs/zerolog"
|
|
|
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
|
)
|
|
|
|
type dataBrokerSyncer struct {
|
|
cfg *atomicConfig
|
|
log zerolog.Logger
|
|
|
|
update chan<- updateRecordsMessage
|
|
clear chan<- struct{}
|
|
|
|
syncer *databroker.Syncer
|
|
}
|
|
|
|
func newDataBrokerSyncer(
|
|
cfg *atomicConfig,
|
|
log zerolog.Logger,
|
|
update chan<- updateRecordsMessage,
|
|
clear chan<- struct{},
|
|
) *dataBrokerSyncer {
|
|
syncer := &dataBrokerSyncer{
|
|
cfg: cfg,
|
|
log: log,
|
|
|
|
update: update,
|
|
clear: clear,
|
|
}
|
|
syncer.syncer = databroker.NewSyncer(syncer)
|
|
return syncer
|
|
}
|
|
|
|
func (syncer *dataBrokerSyncer) Run(ctx context.Context) (err error) {
|
|
return syncer.syncer.Run(ctx)
|
|
}
|
|
|
|
func (syncer *dataBrokerSyncer) ClearRecords(ctx context.Context) {
|
|
select {
|
|
case <-ctx.Done():
|
|
case syncer.clear <- struct{}{}:
|
|
}
|
|
}
|
|
|
|
func (syncer *dataBrokerSyncer) GetDataBrokerServiceClient() databroker.DataBrokerServiceClient {
|
|
return syncer.cfg.Load().dataBrokerClient
|
|
}
|
|
|
|
func (syncer *dataBrokerSyncer) UpdateRecords(ctx context.Context, records []*databroker.Record) {
|
|
select {
|
|
case <-ctx.Done():
|
|
case syncer.update <- updateRecordsMessage{records: records}:
|
|
}
|
|
}
|