MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetBucketSpec

Function GetBucketSpec

rest/server_context.go:601–652  ·  view source on GitHub ↗

GetBucketSpec returns a BucketSpec from a given DatabaseConfig and StartupConfig.

(ctx context.Context, config *DatabaseConfig, serverConfig *StartupConfig)

Source from the content-addressed store, hash-verified

599
600// GetBucketSpec returns a BucketSpec from a given DatabaseConfig and StartupConfig.
601func GetBucketSpec(ctx context.Context, config *DatabaseConfig, serverConfig *StartupConfig) (base.BucketSpec, error) {
602
603 var server string
604 if config.Server != nil {
605 server = *config.Server
606 } else {
607 server = serverConfig.Bootstrap.Server
608 }
609 if serverConfig.IsServerless() {
610 params := base.DefaultServerlessGoCBConnStringParams()
611 if config.Unsupported != nil {
612 if config.Unsupported.DCPReadBuffer != 0 {
613 params.DcpBufferSize = config.Unsupported.DCPReadBuffer
614 }
615 if config.Unsupported.KVBufferSize != 0 {
616 params.KvBufferSize = config.Unsupported.KVBufferSize
617 }
618 }
619 connStr, err := base.GetGoCBConnStringWithDefaults(server, params)
620 if err != nil {
621 return base.BucketSpec{}, err
622 }
623 server = connStr
624 }
625
626 spec := config.MakeBucketSpec(server)
627
628 if serverConfig.Bootstrap.ServerTLSSkipVerify != nil {
629 spec.TLSSkipVerify = *serverConfig.Bootstrap.ServerTLSSkipVerify
630 }
631
632 if spec.BucketName == "" {
633 spec.BucketName = config.Name
634 }
635
636 spec.FeedType = strings.ToLower(config.FeedType)
637
638 if config.ViewQueryTimeoutSecs != nil {
639 spec.ViewQueryTimeoutSecs = config.ViewQueryTimeoutSecs
640 }
641
642 spec.UseXattrs = config.UseXattrs()
643 if !spec.UseXattrs {
644 base.WarnfCtx(ctx, "Running Sync Gateway without shared bucket access is deprecated. Recommendation: set enable_shared_bucket_access=true")
645 }
646
647 if config.BucketOpTimeoutMs != nil {
648 operationTimeout := time.Millisecond * time.Duration(*config.BucketOpTimeoutMs)
649 spec.BucketOpTimeout = &operationTimeout
650 }
651 return spec, nil
652}
653
654// Adds a database to the ServerContext. Attempts a read after it gets the write
655// lock to see if it's already been added by another process. If so, returns either the

Callers 3

handleFlushMethod · 0.85

Calls 6

WarnfCtxFunction · 0.92
IsServerlessMethod · 0.80
MakeBucketSpecMethod · 0.80
UseXattrsMethod · 0.45

Tested by 1