Skip to content

Commit

Permalink
Embed policies as values and not pointers inside each other
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed Mar 20, 2019
1 parent 2c33dca commit 19ff33a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Makes `OperationType` private.
- Remove long deprecated method for pool management.
- Removes unused `ReadN` method in `Connection`.
- Embeds Policies as values and not pointers inside `MultiPolicy`, `ScanPolicy`, `QueryPolicy`

* **Minor**:
- Fixes a race condition in the `AdminCommand`.
Expand Down
6 changes: 3 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func (cmd *baseCommand) setScan(policy *ScanPolicy, namespace *string, setName *
if binNames != nil {
operationCount = len(binNames)
}
cmd.writeHeader(policy.BasePolicy, readAttr, 0, fieldCount, operationCount)
cmd.writeHeader(&policy.BasePolicy, readAttr, 0, fieldCount, operationCount)

if namespace != nil {
cmd.writeFieldString(*namespace, NAMESPACE)
Expand Down Expand Up @@ -876,13 +876,13 @@ func (cmd *baseCommand) setQuery(policy *QueryPolicy, statement *Statement, writ
}

if write {
cmd.writeHeader(policy.BasePolicy, _INFO1_READ, _INFO2_WRITE, fieldCount, operationCount)
cmd.writeHeader(&policy.BasePolicy, _INFO1_READ, _INFO2_WRITE, fieldCount, operationCount)
} else {
readAttr := _INFO1_READ | _INFO1_NOBINDATA
if policy.IncludeBinData {
readAttr = _INFO1_READ
}
cmd.writeHeader(policy.BasePolicy, readAttr, 0, fieldCount, operationCount)
cmd.writeHeader(&policy.BasePolicy, readAttr, 0, fieldCount, operationCount)
}

if statement.Namespace != "" {
Expand Down
4 changes: 2 additions & 2 deletions multi_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "time"
// MultiPolicy contains parameters for policy attributes used in
// query and scan operations.
type MultiPolicy struct {
*BasePolicy
BasePolicy

// Maximum number of concurrent requests to server nodes at any poin int time.
// If there are 16 nodes in the cluster and maxConcurrentNodes is 8, then queries
Expand All @@ -43,7 +43,7 @@ type MultiPolicy struct {

// NewMultiPolicy initializes a MultiPolicy instance with default values.
func NewMultiPolicy() *MultiPolicy {
bp := NewPolicy()
bp := *NewPolicy()
bp.SocketTimeout = 30 * time.Second

return &MultiPolicy{
Expand Down
4 changes: 2 additions & 2 deletions query_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ package aerospike

// QueryPolicy encapsulates parameters for policy attributes used in query operations.
type QueryPolicy struct {
*MultiPolicy
MultiPolicy
}

// NewQueryPolicy generates a new QueryPolicy instance with default values.
func NewQueryPolicy() *QueryPolicy {
return &QueryPolicy{
MultiPolicy: NewMultiPolicy(),
MultiPolicy: *NewMultiPolicy(),
}
}
4 changes: 2 additions & 2 deletions scan_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package aerospike

// ScanPolicy encapsulates parameters used in scan operations.
type ScanPolicy struct {
*MultiPolicy
MultiPolicy

// ScanPercent determines percent of data to scan.
// Valid integer range is 1 to 100.
Expand All @@ -29,7 +29,7 @@ type ScanPolicy struct {

// NewScanPolicy creates a new ScanPolicy instance with default values.
func NewScanPolicy() *ScanPolicy {
mp := NewMultiPolicy()
mp := *NewMultiPolicy()
mp.TotalTimeout = 0

return &ScanPolicy{
Expand Down

0 comments on commit 19ff33a

Please sign in to comment.