Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
added support for cached roster repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ortuman committed Feb 8, 2022
1 parent 6db435c commit 74767c5
Show file tree
Hide file tree
Showing 21 changed files with 692 additions and 83 deletions.
244 changes: 220 additions & 24 deletions pkg/model/roster/roster.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ package router
import (
"context"

c2smodel "github.com/ortuman/jackal/pkg/model/c2s"

"github.com/jackal-xmpp/stravaganza/v2"
streamerror "github.com/jackal-xmpp/stravaganza/v2/errors/stream"
"github.com/jackal-xmpp/stravaganza/v2/jid"
"github.com/ortuman/jackal/pkg/host"
c2smodel "github.com/ortuman/jackal/pkg/model/c2s"
"github.com/ortuman/jackal/pkg/router/stream"
)

Expand All @@ -33,10 +32,10 @@ type Router interface {
// (https://xmpp.org/rfcs/rfc3921.html#rules)
Route(ctx context.Context, stanza stravaganza.Stanza) (targets []jid.JID, err error)

// C2SRouter returns the underlying C2S router.
// C2S returns the underlying C2S router.
C2S() C2SRouter

// S2SRouter returns the underlying S2S router.
// S2S returns the underlying S2S router.
S2S() S2SRouter

// Start starts global router subsystem.
Expand Down
12 changes: 6 additions & 6 deletions pkg/storage/cached/blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ type cachedBlockListRep struct {

func (c *cachedBlockListRep) UpsertBlockListItem(ctx context.Context, item *blocklistmodel.Item) error {
op := updateOp{
c: c.c,
namespace: blockListNS(item.Username),
invalidKeys: []string{blockListItems},
c: c.c,
namespace: blockListNS(item.Username),
invalidateKeys: []string{blockListItems},
updateFn: func(ctx context.Context) error {
return c.rep.UpsertBlockListItem(ctx, item)
},
Expand All @@ -67,9 +67,9 @@ func (c *cachedBlockListRep) UpsertBlockListItem(ctx context.Context, item *bloc

func (c *cachedBlockListRep) DeleteBlockListItem(ctx context.Context, item *blocklistmodel.Item) error {
op := updateOp{
c: c.c,
namespace: blockListNS(item.Username),
invalidKeys: []string{blockListItems},
c: c.c,
namespace: blockListNS(item.Username),
invalidateKeys: []string{blockListItems},
updateFn: func(ctx context.Context) error {
return c.rep.DeleteBlockListItem(ctx, item)
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/cached/cached.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The jackal Authors
// Copyright 2022 The jackal Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@ type Cache interface {
// Put stores a value into the cache store.
Put(ctx context.Context, ns, key string, val []byte) error

// Del removes k value from the cache store.
// Del removes keys values from the cache store.
Del(ctx context.Context, ns string, keys ...string) error

// DelNS removes all keys contained under a given namespace from the cache store.
Expand Down Expand Up @@ -89,7 +89,7 @@ func New(cfg Config, rep repository.Repository, logger kitlog.Logger) (repositor
Capabilities: &cachedCapsRep{c: c, rep: rep},
Private: &cachedPrivateRep{c: c, rep: rep},
BlockList: &cachedBlockListRep{c: c, rep: rep},
Roster: rep,
Roster: &cachedRosterRep{c: c, rep: rep},
VCard: &cachedVCardRep{c: c, rep: rep},
Offline: rep,
Locker: rep,
Expand Down
Loading

0 comments on commit 74767c5

Please sign in to comment.