Skip to content

Commit

Permalink
Fix a bunch of golint notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertJohan committed Jun 22, 2015
1 parent 6ab37ae commit cf4d8ea
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 52 deletions.
2 changes: 1 addition & 1 deletion admin_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package aerospike

import "time"

// Policy attributes used for user administration commands.
// AdminPolicy contains attributes used for user administration commands.
type AdminPolicy struct {

// User administration command socket timeout in milliseconds.
Expand Down
33 changes: 14 additions & 19 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ func (clnt *Client) DropIndex(
// User administration
//-------------------------------------------------------

// Create user with password and roles. Clear-text password will be hashed using bcrypt
// CreateUser creates a new user with password and roles. Clear-text password will be hashed using bcrypt
// before sending to server.
func (clnt *Client) CreateUser(policy *AdminPolicy, user string, password string, roles []string) error {
policy = clnt.getUsableAdminPolicy(policy)
Expand All @@ -1038,15 +1038,15 @@ func (clnt *Client) CreateUser(policy *AdminPolicy, user string, password string
return command.createUser(clnt.cluster, policy, user, hash, roles)
}

// Remove user from cluster.
// DropUser removes a user from the cluster.
func (clnt *Client) DropUser(policy *AdminPolicy, user string) error {
policy = clnt.getUsableAdminPolicy(policy)

command := newAdminCommand()
return command.dropUser(clnt.cluster, policy, user)
}

// Change user's password. Clear-text password will be hashed using bcrypt before sending to server.
// ChangePassword changes a user's password. Clear-text password will be hashed using bcrypt before sending to server.
func (clnt *Client) ChangePassword(policy *AdminPolicy, user string, password string) error {
policy = clnt.getUsableAdminPolicy(policy)

Expand Down Expand Up @@ -1077,31 +1077,31 @@ func (clnt *Client) ChangePassword(policy *AdminPolicy, user string, password st
return nil
}

// Add roles to user's list of roles.
// GrantRoles adds roles to user's list of roles.
func (clnt *Client) GrantRoles(policy *AdminPolicy, user string, roles []string) error {
policy = clnt.getUsableAdminPolicy(policy)

command := newAdminCommand()
return command.grantRoles(clnt.cluster, policy, user, roles)
}

// Remove roles from user's list of roles.
// RevokeRoles removes roles from user's list of roles.
func (clnt *Client) RevokeRoles(policy *AdminPolicy, user string, roles []string) error {
policy = clnt.getUsableAdminPolicy(policy)

command := newAdminCommand()
return command.revokeRoles(clnt.cluster, policy, user, roles)
}

// Retrieve roles for a given user.
// QueryUser retrieves roles for a given user.
func (clnt *Client) QueryUser(policy *AdminPolicy, user string) (*UserRoles, error) {
policy = clnt.getUsableAdminPolicy(policy)

command := newAdminCommand()
return command.queryUser(clnt.cluster, policy, user)
}

// Retrieve all users and their roles.
// QueryUsers retrieves all users and their roles.
func (clnt *Client) QueryUsers(policy *AdminPolicy) ([]*UserRoles, error) {
policy = clnt.getUsableAdminPolicy(policy)

Expand Down Expand Up @@ -1179,9 +1179,8 @@ func (clnt *Client) getUsablePolicy(policy *BasePolicy) *BasePolicy {
if policy == nil {
if clnt.DefaultPolicy != nil {
return clnt.DefaultPolicy
} else {
return NewPolicy()
}
return NewPolicy()
}
return policy
}
Expand All @@ -1190,9 +1189,8 @@ func (clnt *Client) getUsableWritePolicy(policy *WritePolicy) *WritePolicy {
if policy == nil {
if clnt.DefaultWritePolicy != nil {
return clnt.DefaultWritePolicy
} else {
return NewWritePolicy(0, 0)
}
return NewWritePolicy(0, 0)
}
return policy
}
Expand All @@ -1201,31 +1199,28 @@ func (clnt *Client) getUsableScanPolicy(policy *ScanPolicy) *ScanPolicy {
if policy == nil {
if clnt.DefaultScanPolicy != nil {
return clnt.DefaultScanPolicy
} else {
return NewScanPolicy()
}
return NewScanPolicy()
}
return policy
}

func (clnt *Client) getUsableQueryPolicy(policy *QueryPolicy) *QueryPolicy {
if policy == nil {
if clnt.DefaultQueryPolicy != nil {
policy = clnt.DefaultQueryPolicy
} else {
policy = NewQueryPolicy()
return clnt.DefaultQueryPolicy
}
return NewQueryPolicy()
}
return policy
}

func (clnt *Client) getUsableAdminPolicy(policy *AdminPolicy) *AdminPolicy {
if policy == nil {
if clnt.DefaultAdminPolicy != nil {
policy = clnt.DefaultAdminPolicy
} else {
policy = NewAdminPolicy()
return clnt.DefaultAdminPolicy
}
return NewAdminPolicy()
}
return policy
}
Expand Down
2 changes: 2 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ func (clstr *Cluster) WaitUntillMigrationIsFinished(timeout time.Duration) (err
}
}

// Password returns the password that is currently used with the cluster.
func (clstr *Cluster) Password() (res []byte) {
clstr.mutex.RLock()
res = clstr.password
Expand All @@ -720,6 +721,7 @@ func (clstr *Cluster) changePassword(user string, password string, hash []byte)
}
}

// ClientPolicy returns the client policy that is currently used with the cluster.
func (clstr *Cluster) ClientPolicy() (res ClientPolicy) {
clstr.mutex.RLock()
res = clstr.clientPolicy
Expand Down
6 changes: 3 additions & 3 deletions commit_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package aerospike

// Desired consistency guarantee when committing a transaction on the server.
// CommitLevel indicates the desired consistency guarantee when committing a transaction on the server.
type CommitLevel int

const (
// Server should wait until successfully committing master and all replicas.
// COMMIT_ALL indicates the server should wait until successfully committing master and all replicas.
COMMIT_ALL CommitLevel = iota

// Server should wait until successfully committing master only.
// COMMIT_MASTER indicates the server should wait until successfully committing master only.
COMMIT_MASTER
)
10 changes: 6 additions & 4 deletions consistency_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

package aerospike

// How replicas should be consulted in a read operation to provide the desired
// consistency guarantee.
// ConsistencyLevel indicates how replicas should be consulted in a read
// operation to provide the desired consistency guarantee.
type ConsistencyLevel int

const (
// Involve a single replica in the operation.
// CONSISTENCY_ONE indicates only a single replica should be consulted in
// the read operation.
CONSISTENCY_ONE = iota

// Involve all replicas in the operation.
// CONSISTENCY_ALL indicates that all replicas should be consulted in
// the read operation.
CONSISTENCY_ALL
)
1 change: 1 addition & 0 deletions field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package aerospike
// FieldType represents the type of the field in Aerospike Wire Protocol
type FieldType int

// FieldType constants used in the Aerospike Wire Protocol.
const (
NAMESPACE FieldType = 0
TABLE FieldType = 1
Expand Down
4 changes: 2 additions & 2 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func NewKey(namespace string, setName string, key interface{}) (newKey *Key, err
return newKey, err
}

// NewKey initializes a key from namespace, optional set name and user key.
// NewKeyWithDigest initializes a key from namespace, optional set name and user key.
// The server handles record identifiers by digest only.
func NewKeyWithDigest(namespace string, setName string, key interface{}, digest []byte) (newKey *Key, err error) {
newKey = &Key{
Expand All @@ -112,7 +112,7 @@ func NewKeyWithDigest(namespace string, setName string, key interface{}, digest
return newKey, err
}

//Set custom hash
// SetDigest sets a custom hash
func (ky *Key) SetDigest(digest []byte) error {
if len(digest) != 20 {
return NewAerospikeError(PARAMETER_ERROR, "Invalid digest: Digest is required to be exactly 20 bytes.")
Expand Down
22 changes: 11 additions & 11 deletions large_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (ll *LargeList) FindThenFilter(value interface{}, filterModule, filterName
return res.([]interface{}), err
}

// Select values from the beginning of list up to a maximum count.
// FindFirst selects values from the beginning of list up to a maximum count.
func (ll *LargeList) FindFirst(count int) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_first", ll.binName, NewValue(count))
if err != nil {
Expand All @@ -84,7 +84,7 @@ func (ll *LargeList) FindFirst(count int) ([]interface{}, error) {
return res.([]interface{}), err
}

// Select values from the beginning of list up to a maximum count after applying lua filter.
// FFilterThenindFirst selects values from the beginning of list up to a maximum count after applying lua filter.
func (ll *LargeList) FFilterThenindFirst(count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_first", ll.binName, NewValue(count), NewValue(filterModule), NewValue(filterName), ToValueArray(filterArgs))
if err != nil {
Expand All @@ -97,7 +97,7 @@ func (ll *LargeList) FFilterThenindFirst(count int, filterModule, filterName str
return res.([]interface{}), err
}

// Select values from the end of list up to a maximum count.
// FindLast selects values from the end of list up to a maximum count.
func (ll *LargeList) FindLast(count int) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_last", ll.binName, NewValue(count))
if err != nil {
Expand All @@ -110,7 +110,7 @@ func (ll *LargeList) FindLast(count int) ([]interface{}, error) {
return res.([]interface{}), err
}

// Select values from the end of list up to a maximum count after applying lua filter.
// FilterThenFindLast selects values from the end of list up to a maximum count after applying lua filter.
func (ll *LargeList) FilterThenFindLast(count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_last", ll.binName, NewValue(count), NewValue(filterModule), NewValue(filterName), ToValueArray(filterArgs))
if err != nil {
Expand All @@ -123,7 +123,7 @@ func (ll *LargeList) FilterThenFindLast(count int, filterModule, filterName stri
return res.([]interface{}), err
}

// Select values from the begin key up to a maximum count.
// FindFrom selects values from the begin key up to a maximum count.
func (ll *LargeList) FindFrom(begin interface{}, count int) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_from", ll.binName, NewValue(begin), NewValue(count))
if err != nil {
Expand All @@ -136,7 +136,7 @@ func (ll *LargeList) FindFrom(begin interface{}, count int) ([]interface{}, erro
return res.([]interface{}), err
}

// Select values from the begin key up to a maximum count after applying lua filter.
// FilterThenFindFrom selects values from the begin key up to a maximum count after applying lua filter.
func (ll *LargeList) FilterThenFindFrom(begin interface{}, count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_from", ll.binName, NewValue(begin), NewValue(count), NewValue(filterModule), NewValue(filterName), ToValueArray(filterArgs))
if err != nil {
Expand All @@ -149,7 +149,7 @@ func (ll *LargeList) FilterThenFindFrom(begin interface{}, count int, filterModu
return res.([]interface{}), err
}

// Select a range of values from the large list.
// Range selects a range of values from the large list.
func (ll *LargeList) Range(begin, end interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_range", ll.binName, NewValue(begin), NewValue(end))
if err != nil {
Expand All @@ -162,7 +162,7 @@ func (ll *LargeList) Range(begin, end interface{}) ([]interface{}, error) {
return res.([]interface{}), err
}

// Select a range of values up to a maximum count from the large list.
// RangeN selects a range of values up to a maximum count from the large list.
func (ll *LargeList) RangeN(begin, end interface{}, count int) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "find_range", ll.binName, NewValue(begin), NewValue(end), NewValue(count))
if err != nil {
Expand All @@ -175,7 +175,7 @@ func (ll *LargeList) RangeN(begin, end interface{}, count int) ([]interface{}, e
return res.([]interface{}), err
}

// Select a range of values from the large list then apply filter.
// RangeThenFilter selects a range of values from the large list then apply filter.
func (ll *LargeList) RangeThenFilter(begin, end interface{}, filterModule string, filterName string, filterArgs ...interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "range", ll.binName, NewValue(begin), NewValue(end), NewValue(0), NewValue(filterModule), NewValue(filterName), ToValueArray(filterArgs))
if err != nil {
Expand All @@ -188,7 +188,7 @@ func (ll *LargeList) RangeThenFilter(begin, end interface{}, filterModule string
return res.([]interface{}), err
}

// Select a range of values up to a maximum count from the large list then apply filter.
// RangeNThenFilter selects a range of values up to a maximum count from the large list then apply filter.
func (ll *LargeList) RangeNThenFilter(begin, end interface{}, count int, filterModule string, filterName string, filterArgs ...interface{}) ([]interface{}, error) {
res, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "range", ll.binName, NewValue(begin), NewValue(end), NewValue(count), NewValue(filterModule), NewValue(filterName), ToValueArray(filterArgs))
if err != nil {
Expand Down Expand Up @@ -229,7 +229,7 @@ func (ll *LargeList) Size() (int, error) {
return ll.size(ll)
}

// Set LDT page size.
// SetPageSize sets the LDT page size.
func (ll *LargeList) SetPageSize(pageSize int) error {
_, err := ll.client.Execute(ll.policy, ll.key, ll.packageName, "setPageSize", ll.binName, NewValue(pageSize))
return err
Expand Down
4 changes: 2 additions & 2 deletions large_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (lm *LargeMap) PutMap(theMap map[interface{}]interface{}) error {
return err
}

// Check existence of key in the map.
// Exists checks existence of key in the map.
func (lm *LargeMap) Exists(keyValue interface{}) (bool, error) {
res, err := lm.client.Execute(lm.policy, lm.key, lm.packageName, "exists", lm.binName, NewValue(keyValue))

Expand All @@ -62,7 +62,7 @@ func (lm *LargeMap) Exists(keyValue interface{}) (bool, error) {
return (res.(int) != 0), err
}

// Get returns value from map corresponding with the provided key.
// Get returns value from map corresponding with the provided key.
func (lm *LargeMap) Get(name interface{}) (map[interface{}]interface{}, error) {
res, err := lm.client.Execute(lm.policy, lm.key, lm.packageName, "get", lm.binName, NewValue(name))

Expand Down
6 changes: 2 additions & 4 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ func valueToInterface(f reflect.Value) interface{} {
case reflect.Struct:
if f.Type().PkgPath() == "time" && f.Type().Name() == "Time" {
return f.Interface().(time.Time).UTC().UnixNano()
} else {
return structToMap(f)
}
return structToMap(f)
case reflect.Bool:
if f.Bool() == true {
return int64(1)
Expand Down Expand Up @@ -95,9 +94,8 @@ func fieldAlias(f reflect.StructField) string {
return ""
}
return alias
} else {
return f.Name
}
return f.Name
}

func structToMap(s reflect.Value) map[string]interface{} {
Expand Down
3 changes: 3 additions & 0 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ package aerospike
// OperationType determines operation type
type OperationType byte

// Valid OperationType values that can be used to create custom Operations.
// The names are self-explanatory.
const (
READ OperationType = 1
// READ_HEADER OperationType = 1

WRITE OperationType = 2
ADD OperationType = 5
APPEND OperationType = 9
Expand Down
8 changes: 4 additions & 4 deletions role.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type Role string

// Pre-defined user roles.
const (
// Manage users their roles.
// UserAdmin allows to manages users and their roles.
UserAdmin Role = "user-admin"

// Manage indicies, user defined functions and server configuration.
// SysAdmin allows to manage indicies, user defined functions and server configuration.
SysAdmin Role = "sys-admin"

// Allow read and write transactions with the database.
// ReadWrite allows read and write transactions with the database.
ReadWrite Role = "read-write"

// Allow read transactions with the database.
// Read allow read transactions with the database.
Read Role = "Read"
)
4 changes: 2 additions & 2 deletions user_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

package aerospike

// User and assigned roles.
// UserRoles contains information about a user.
type UserRoles struct {
// User name.
User string

// List of assigned roles.
// Roles is a list of assigned roles.
Roles []string
}

0 comments on commit cf4d8ea

Please sign in to comment.