Files
llink/go/internal/livestore/membershippublisher.go
T
Arjun Patel e3461dd5cd mobile v0.1 with deployment for ios (#191)
* stage 1: project init

* stage 2: skeleton with navigation

* step 2.5: streams list

* step 4: stream playback experience

* step 5-6: compose experience

* fix: broken record

* transcode media particles to mp4

* build: reproducible go generate

* build: rename skaffold module for particle processor worker

* infra: increase particle processor worker resources

Was dealing with OOM errors

* tweaks to mobile

* log transcode work

* view on desktop placeholder

* tweak padding

* cap video resolution to save on memory

* infra: bump memory limits as insurance

* ux improvements

* update bundle id for mobile

* config for mobile
2026-04-29 17:39:11 -07:00

43 lines
1.4 KiB
Go

package livestore
import (
"context"
"cloud.google.com/go/firestore"
)
//go:generate go tool mockgen -source ./membershippublisher.go -destination ./mocks/membershippublisher.go
// MembershipPublisher publishes network membership changes to the live store
// (Firestore) that clients subscribe to. Postgres remains the source of truth;
// the membership reconciler heals any drift, so callers may log and ignore
// publish failures.
type MembershipPublisher interface {
Add(ctx context.Context, humanId, networkID string) error
Remove(ctx context.Context, humanId, networkID string) error
}
func NewMembershipPublisher(fs *firestore.Client) MembershipPublisher {
return &firestoreMembershipPublisher{fs: fs}
}
type firestoreMembershipPublisher struct {
fs *firestore.Client
}
func (p *firestoreMembershipPublisher) Add(ctx context.Context, humanId, networkID string) error {
_, err := p.fs.Collection("humans").Doc(humanId).Set(ctx, map[string]any{
"networks": firestore.ArrayUnion(networkID),
"updated_at": firestore.ServerTimestamp,
}, firestore.MergeAll)
return err
}
func (p *firestoreMembershipPublisher) Remove(ctx context.Context, humanId, networkID string) error {
_, err := p.fs.Collection("humans").Doc(humanId).Set(ctx, map[string]any{
"networks": firestore.ArrayRemove(networkID),
"updated_at": firestore.ServerTimestamp,
}, firestore.MergeAll)
return err
}