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

Function ParseSubprotocolString

db/blip_subprotocol.go:44–57  ·  view source on GitHub ↗

ParseSubprotocolString takes a 'CBMobile_' prefixed string and returns the subprotocol version.

(s string)

Source from the content-addressed store, hash-verified

42
43// ParseSubprotocolString takes a 'CBMobile_' prefixed string and returns the subprotocol version.
44func ParseSubprotocolString(s string) (CBMobileSubprotocolVersion, error) {
45 vStr, ok := strings.CutPrefix(s, cbMobileBLIPSubprotocolPrefix)
46 if !ok {
47 return 0, fmt.Errorf("invalid subprotocol string: %q", s)
48 }
49 v, err := strconv.Atoi(vStr)
50 if err != nil {
51 return 0, fmt.Errorf("invalid subprotocol string: %q: %w", s, err)
52 }
53 if v < int(minCBMobileSubprotocolVersion) || v > int(maxCBMobileSubprotocolVersion) {
54 return 0, fmt.Errorf("invalid subprotocol version: %q", s)
55 }
56 return CBMobileSubprotocolVersion(v), nil
57}
58
59// supportedSubprotocols returns a list of supported subprotocol versions, in order of most preferred first
60func supportedSubprotocols() []string {

Callers 6

UseHLVMethod · 0.92
AssertOnBlipHistoryMethod · 0.92
createBlipTesterWithSpecFunction · 0.92
TestSubprotocolStringFunction · 0.85

Calls 2

ErrorfMethod · 0.80

Tested by 1

TestSubprotocolStringFunction · 0.68