blob: f0236c01a7d5b411cd4d6e1e7f2d3305bfef37d6 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package description
8
9import (
10 "fmt"
11)
12
13// MaxStalenessSupported returns an error if the given server version
14// does not support max staleness.
15func MaxStalenessSupported(wireVersion *VersionRange) error {
16 if wireVersion != nil && wireVersion.Max < 5 {
17 return fmt.Errorf("max staleness is only supported for servers 3.4 or newer")
18 }
19
20 return nil
21}
22
23// ScramSHA1Supported returns an error if the given server version
24// does not support scram-sha-1.
25func ScramSHA1Supported(wireVersion *VersionRange) error {
26 if wireVersion != nil && wireVersion.Max < 3 {
27 return fmt.Errorf("SCRAM-SHA-1 is only supported for servers 3.0 or newer")
28 }
29
30 return nil
31}
32
33// SessionsSupported returns true of the given server version indicates that it supports sessions.
34func SessionsSupported(wireVersion *VersionRange) bool {
35 return wireVersion != nil && wireVersion.Max >= 6
36}