Skip to content

Commit

Permalink
GOCBC-1637: Refactor views to use providers pattern
Browse files Browse the repository at this point in the history
Motivation
----------
As a part of adding support for protostellar we have moved most
components to uase a provider pattern, however there are some
components that still aren't using that pattern.

Changes
--------
Refactor view query and view indexes to use providers pattern.

Change-Id: I350389002f1ded4fb994e180434904ba77d8d417
Reviewed-on: https://review.couchbase.org/c/gocb/+/210852
Reviewed-by: Dimitris Christodoulou <dimitris.christodoulou@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
chvck committed Jun 6, 2024
1 parent e3a7c54 commit 4754dcc
Show file tree
Hide file tree
Showing 18 changed files with 802 additions and 510 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ updatemocks:
mockery --name=queryProviderCoreProvider --output=. --testonly --inpackage
mockery --name=searchProviderCoreProvider --output=. --testonly --inpackage
mockery --name=searchCapabilityVerifier --output=. --testonly --inpackage
mockery --name=viewProviderCoreProvider --output=. --testonly --inpackage
# pendingOp is manually mocked

.PHONY: all test devsetup fasttest lint cover check bench updatetestcases updatemocks
27 changes: 23 additions & 4 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ func (b *Bucket) getEventingManagementProvider() (eventingManagementProvider, er
return provider, nil
}

func (b *Bucket) getViewProvider(bucketName string) (viewProvider, error) {
provider, err := b.connectionManager.getViewProvider(bucketName)
if err != nil {
return nil, err
}

return provider, nil
}

func (b *Bucket) getViewIndexProvider(bucketName string) (viewIndexProvider, error) {
provider, err := b.connectionManager.getViewIndexProvider(bucketName)
if err != nil {
return nil, err
}

return provider, nil
}

// Name returns the name of the bucket.
func (b *Bucket) Name() string {
return b.bucketName
Expand Down Expand Up @@ -179,10 +197,11 @@ func (b *Bucket) DefaultCollection() *Collection {
// ViewIndexes returns a ViewIndexManager instance for managing views.
func (b *Bucket) ViewIndexes() *ViewIndexManager {
return &ViewIndexManager{
mgmtProvider: b,
bucketName: b.Name(),
tracer: b.tracer,
meter: b.meter,
getProvider: func() (viewIndexProvider, error) {
return b.getViewIndexProvider(b.Name())
},
tracer: b.tracer,
meter: b.meter,
}
}

Expand Down
Loading

0 comments on commit 4754dcc

Please sign in to comment.