Skip to content

Commit

Permalink
Deduplicate types in some func signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan authored and buger committed Feb 11, 2017
1 parent fc83a4b commit 3f96ea4
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
20 changes: 10 additions & 10 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetSpecForOrg(APIID string) *APISpec {
return ApiSpecRegister[aKey]
}

func checkAndApplyTrialPeriod(keyName string, apiId string, newSession *SessionState) {
func checkAndApplyTrialPeriod(keyName, apiId string, newSession *SessionState) {
// Check the policy to see if we are forcing an expiry on the key
if newSession.ApplyPolicyID != "" {
policy, ok := Policies[newSession.ApplyPolicyID]
Expand Down Expand Up @@ -202,7 +202,7 @@ func SetSessionPassword(session *SessionState) {
session.BasicAuthData.Password = string(newPass)
}

func GetKeyDetail(key string, APIID string) (SessionState, bool) {
func GetKeyDetail(key, APIID string) (SessionState, bool) {

sessionManager := FallbackKeySesionManager
if APIID != "" {
Expand Down Expand Up @@ -313,7 +313,7 @@ func handleAddOrUpdate(keyName string, r *http.Request) ([]byte, int) {
return responseMessage, code
}

func handleGetDetail(sessionKey string, APIID string) ([]byte, int) {
func handleGetDetail(sessionKey, APIID string) ([]byte, int) {
success := true
var responseMessage []byte
var err error
Expand Down Expand Up @@ -367,7 +367,7 @@ type APIAllKeys struct {
APIKeys []string `json:"keys"`
}

func handleGetAllKeys(filter string, APIID string) ([]byte, int) {
func handleGetAllKeys(filter, APIID string) ([]byte, int) {
success := true
var responseMessage []byte
code := 200
Expand Down Expand Up @@ -438,7 +438,7 @@ type APIStatusMessage struct {
Message string `json:"message"`
}

func handleDeleteKey(keyName string, APIID string) ([]byte, int) {
func handleDeleteKey(keyName, APIID string) ([]byte, int) {
var responseMessage []byte
var err error

Expand Down Expand Up @@ -506,7 +506,7 @@ func handleDeleteKey(keyName string, APIID string) ([]byte, int) {
return responseMessage, code
}

func handleDeleteHashedKey(keyName string, APIID string) ([]byte, int) {
func handleDeleteHashedKey(keyName, APIID string) ([]byte, int) {
var responseMessage []byte
var err error

Expand Down Expand Up @@ -885,7 +885,7 @@ func policyUpdateHandler(w http.ResponseWriter, r *http.Request) {
DoJSONWrite(w, code, responseMessage)
}

func handleUpdateHashedKey(keyName string, APIID string, policyId string) ([]byte, int) {
func handleUpdateHashedKey(keyName, APIID, policyId string) ([]byte, int) {
var responseMessage []byte
var err error

Expand Down Expand Up @@ -1461,7 +1461,7 @@ type NewClientRequest struct {
ClientSecret string `json:"secret"`
}

func createOauthClientStorageID(APIID string, clientID string) string {
func createOauthClientStorageID(APIID, clientID string) string {
return CLIENT_PREFIX + clientID
}

Expand Down Expand Up @@ -1691,7 +1691,7 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) {
}

// Get client details
func getOauthClientDetails(keyName string, APIID string) ([]byte, int) {
func getOauthClientDetails(keyName, APIID string) ([]byte, int) {
success := true
var responseMessage []byte
var err error
Expand Down Expand Up @@ -1753,7 +1753,7 @@ func getOauthClientDetails(keyName string, APIID string) ([]byte, int) {
}

// Delete Client
func handleDeleteOAuthClient(keyName string, APIID string) ([]byte, int) {
func handleDeleteOAuthClient(keyName, APIID string) ([]byte, int) {
var responseMessage []byte

storageID := createOauthClientStorageID(APIID, keyName)
Expand Down
2 changes: 1 addition & 1 deletion api_definition_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (a *APIDefinitionLoader) readBody(response *http.Response) ([]byte, error)
}

// LoadDefinitionsFromDashboardService will connect and download ApiDefintions from a Tyk Dashboard instance.
func (a *APIDefinitionLoader) LoadDefinitionsFromDashboardService(endpoint string, secret string) []*APISpec {
func (a *APIDefinitionLoader) LoadDefinitionsFromDashboardService(endpoint, secret string) []*APISpec {
var APISpecs = []*APISpec{}

// Get the definitions
Expand Down
2 changes: 1 addition & 1 deletion api_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func skipSpecBecauseInvalid(referenceSpec *APISpec) bool {
return false
}

func generateDomainPath(hostname string, listenPath string) string {
func generateDomainPath(hostname, listenPath string) string {
return hostname + listenPath
}

Expand Down
2 changes: 1 addition & 1 deletion coprocess_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func PythonLoadDispatcher() (err error) {
}

// PythonNewDispatcher creates an instance of TykDispatcher.
func PythonNewDispatcher(middlewarePath string, eventHandlerPath string, bundlePaths []string) (dispatcher coprocess.Dispatcher, err error) {
func PythonNewDispatcher(middlewarePath, eventHandlerPath string, bundlePaths []string) (dispatcher coprocess.Dispatcher, err error) {
CMiddlewarePath := C.CString(middlewarePath)
CEventHandlerPath := C.CString(eventHandlerPath)
CBundlePaths := C.CString(strings.Join(bundlePaths, ":"))
Expand Down
4 changes: 2 additions & 2 deletions coprocess_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (d *TestDispatcher) TestMessageLength(messagePtr unsafe.Pointer) int {
return int(C.TestMessageLength(message))
}

func TestTykStoreData(key string, value string, ttl int) {
func TestTykStoreData(key, value string, ttl int) {
Ckey := C.CString(key)
Cvalue := C.CString(value)
Cttl := C.int(ttl)
Expand All @@ -117,7 +117,7 @@ func TestTykGetData(key string) string {

/* Events */

func TestTykTriggerEvent(eventName string, eventPayload string) {
func TestTykTriggerEvent(eventName, eventPayload string) {
CeventName := C.CString(eventName)
CeventPayload := C.CString(eventPayload)
TykTriggerEvent(CeventName, CeventPayload)
Expand Down
2 changes: 1 addition & 1 deletion dashboard_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (h *HTTPDashboardHandler) StopBeating() {
h.heartBeatStopSentinel = true
}

func (h *HTTPDashboardHandler) SendHeartBeat(endpoint string, secret string) error {
func (h *HTTPDashboardHandler) SendHeartBeat(endpoint, secret string) error {
// Get the definitions
log.Debug("Calling: ", endpoint)
newRequest, err := http.NewRequest("GET", endpoint, nil)
Expand Down
12 changes: 6 additions & 6 deletions instrumentation_statsd_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ func (s *StatsDSink) Drain() {
<-s.drainDoneChan
}

func (s *StatsDSink) EmitEvent(job string, event string, kvs map[string]string) {
func (s *StatsDSink) EmitEvent(job, event string, kvs map[string]string) {
s.cmdChan <- statsdEmitCmd{Kind: statsdCmdKindEvent, Job: job, Event: event}
}

func (s *StatsDSink) EmitEventErr(job string, event string, inputErr error, kvs map[string]string) {
func (s *StatsDSink) EmitEventErr(job, event string, inputErr error, kvs map[string]string) {
s.cmdChan <- statsdEmitCmd{Kind: statsdCmdKindEventErr, Job: job, Event: event}
}

func (s *StatsDSink) EmitTiming(job string, event string, nanos int64, kvs map[string]string) {
func (s *StatsDSink) EmitTiming(job, event string, nanos int64, kvs map[string]string) {
s.cmdChan <- statsdEmitCmd{Kind: statsdCmdKindTiming, Job: job, Event: event, Nanos: nanos}
}

func (s *StatsDSink) EmitGauge(job string, event string, value float64, kvs map[string]string) {
func (s *StatsDSink) EmitGauge(job, event string, value float64, kvs map[string]string) {
s.cmdChan <- statsdEmitCmd{Kind: statsdCmdKindGauge, Job: job, Event: event, Value: value}
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *StatsDSink) processEvent(job, event, extra string) {
}
}

func (s *StatsDSink) processTiming(job string, event string, nanos int64) {
func (s *StatsDSink) processTiming(job, event string, nanos int64) {
s.writeNanosToTimingBuf(nanos)

if !s.options.SkipTopLevelEvents {
Expand All @@ -239,7 +239,7 @@ func (s *StatsDSink) processTiming(job string, event string, nanos int64) {
}
}

func (s *StatsDSink) processGauge(job string, event string, value float64) {
func (s *StatsDSink) processGauge(job, event string, value float64) {
s.timingBuf = s.timingBuf[0:0]
prec := 2
if value < 0.1 && value > -0.1 {
Expand Down
8 changes: 4 additions & 4 deletions ldap_auth_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (l *LDAPStorageHandler) GetKeysAndValuesWithFilter(filter string) map[strin
return s
}

func (l *LDAPStorageHandler) SetKey(cn string, sessionState string, timeout int64) error {
func (l *LDAPStorageHandler) SetKey(cn, sessionState string, timeout int64) error {
l.notifyReadOnly()
return nil
}

func (l *LDAPStorageHandler) SetRawKey(cn string, sessionState string, timeout int64) error {
func (l *LDAPStorageHandler) SetRawKey(cn, sessionState string, timeout int64) error {
l.notifyReadOnly()
return nil
}
Expand Down Expand Up @@ -169,11 +169,11 @@ func (s LDAPStorageHandler) GetSet(keyName string) (map[string]string, error) {
return map[string]string{}, nil
}

func (s LDAPStorageHandler) AddToSet(keyName string, value string) {
func (s LDAPStorageHandler) AddToSet(keyName, value string) {
log.Error("Not implemented")
}

func (s LDAPStorageHandler) RemoveFromSet(keyName string, value string) {
func (s LDAPStorageHandler) RemoveFromSet(keyName, value string) {
log.Error("Not implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion middleware_HMAC.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func generateHMACSignatureStringFromRequest(r *http.Request, fieldValues *HMACFi
return signatureString, nil
}

func generateEncodedSignature(signatureString string, secret string) string {
func generateEncodedSignature(signatureString, secret string) string {
key := []byte(secret)
h := hmac.New(sha1.New, key)
h.Write([]byte(signatureString))
Expand Down
4 changes: 2 additions & 2 deletions middleware_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (a *JWTMiddleware) IsEnabledForSpec() bool {
return true
}

func (k *JWTMiddleware) getSecretFromURL(url string, kid string, keyType string) ([]byte, error) {
func (k *JWTMiddleware) getSecretFromURL(url, kid, keyType string) ([]byte, error) {
// Implement a cache
if JWKCache == nil {
log.Debug("Creating JWK Cache")
Expand Down Expand Up @@ -445,7 +445,7 @@ func (k *JWTMiddleware) setContextVars(r *http.Request, token *jwt.Token) {
}
}

func generateSessionFromPolicy(policyID string, OrgID string, enforceOrg bool) (SessionState, error) {
func generateSessionFromPolicy(policyID, OrgID string, enforceOrg bool) (SessionState, error) {
log.Debug("Generating from policyID: ", policyID)
log.Debug(Policies)
policy, ok := Policies[policyID]
Expand Down
2 changes: 1 addition & 1 deletion oauth_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func (r *RedisOsinStorageInterface) RemoveRefresh(token string) error {
type AccessTokenGenTyk struct{}

// GenerateAccessToken generates base64-encoded UUID access and refresh tokens
func (a *AccessTokenGenTyk) GenerateAccessToken(data *osin.AccessData, generaterefresh bool) (accesstoken string, refreshtoken string, err error) {
func (a *AccessTokenGenTyk) GenerateAccessToken(data *osin.AccessData, generaterefresh bool) (accesstoken, refreshtoken string, err error) {
log.Info("[OAuth] Generating new token")

var newSession SessionState
Expand Down
2 changes: 1 addition & 1 deletion policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func LoadPoliciesFromFile(filePath string) map[string]Policy {
}

// LoadPoliciesFromDashboard will connect and download Policies from a Tyk Dashboard instance.
func LoadPoliciesFromDashboard(endpoint string, secret string, allowExplicit bool) map[string]Policy {
func LoadPoliciesFromDashboard(endpoint, secret string, allowExplicit bool) map[string]Policy {

policies := make(map[string]Policy)

Expand Down
12 changes: 6 additions & 6 deletions redis_cluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r *RedisClusterStorageManager) GetExp(keyName string) (int64, error) {
}

// SetKey will create (or update) a key value in the store
func (r *RedisClusterStorageManager) SetKey(keyName string, sessionState string, timeout int64) error {
func (r *RedisClusterStorageManager) SetKey(keyName, sessionState string, timeout int64) error {
log.Debug("[STORE] SET Raw key is: ", keyName)
log.Debug("[STORE] Setting key: ", r.fixKey(keyName))

Expand All @@ -204,7 +204,7 @@ func (r *RedisClusterStorageManager) SetKey(keyName string, sessionState string,
return nil
}

func (r *RedisClusterStorageManager) SetRawKey(keyName string, sessionState string, timeout int64) error {
func (r *RedisClusterStorageManager) SetRawKey(keyName, sessionState string, timeout int64) error {

if GetRelevantClusterReference(r.IsCache) == nil {
log.Info("Connection dropped, connecting..")
Expand Down Expand Up @@ -532,7 +532,7 @@ func (r *RedisClusterStorageManager) StartPubSubHandler(channel string, callback
}
}

func (r *RedisClusterStorageManager) Publish(channel string, message string) error {
func (r *RedisClusterStorageManager) Publish(channel, message string) error {
if GetRelevantClusterReference(r.IsCache) == nil {
log.Info("Connection dropped, Connecting..")
r.Connect()
Expand Down Expand Up @@ -588,7 +588,7 @@ func (r *RedisClusterStorageManager) GetAndDeleteSet(keyName string) []interface
return []interface{}{}
}

func (r *RedisClusterStorageManager) AppendToSet(keyName string, value string) {
func (r *RedisClusterStorageManager) AppendToSet(keyName, value string) {
log.Debug("Pushing to raw key list: ", keyName)
log.Debug("Appending to fixed key list: ", r.fixKey(keyName))
if GetRelevantClusterReference(r.IsCache) == nil {
Expand Down Expand Up @@ -633,7 +633,7 @@ func (r *RedisClusterStorageManager) GetSet(keyName string) (map[string]string,
return map[string]string{}, nil
}

func (r *RedisClusterStorageManager) AddToSet(keyName string, value string) {
func (r *RedisClusterStorageManager) AddToSet(keyName, value string) {
log.Debug("Pushing to raw key set: ", keyName)
log.Debug("Pushing to fixed key set: ", r.fixKey(keyName))
if GetRelevantClusterReference(r.IsCache) == nil {
Expand All @@ -652,7 +652,7 @@ func (r *RedisClusterStorageManager) AddToSet(keyName string, value string) {
}
}

func (r *RedisClusterStorageManager) RemoveFromSet(keyName string, value string) {
func (r *RedisClusterStorageManager) RemoveFromSet(keyName, value string) {
log.Debug("Removing from raw key set: ", keyName)
log.Debug("Removing from fixed key set: ", r.fixKey(keyName))
if GetRelevantClusterReference(r.IsCache) == nil {
Expand Down
2 changes: 1 addition & 1 deletion rpc_backup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func decrypt(key []byte, cryptoText string) string {
return fmt.Sprintf("%s", ciphertext)
}

func rightPad2Len(s string, padStr string, overallLen int) string {
func rightPad2Len(s, padStr string, overallLen int) string {
padCountInt := 1 + (overallLen-len(padStr))/len(padStr)
retStr := s + strings.Repeat(padStr, padCountInt)
return retStr[:overallLen]
Expand Down
18 changes: 9 additions & 9 deletions rpc_storage_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (r *RPCStorageHandler) GetExp(keyName string) (int64, error) {
}

// SetKey will create (or update) a key value in the store
func (r *RPCStorageHandler) SetKey(keyName string, sessionState string, timeout int64) error {
func (r *RPCStorageHandler) SetKey(keyName, sessionState string, timeout int64) error {
start := time.Now() // get current time
ibd := InboundData{
KeyName: r.fixKey(keyName),
Expand All @@ -367,7 +367,7 @@ func (r *RPCStorageHandler) SetKey(keyName string, sessionState string, timeout

}

func (r *RPCStorageHandler) SetRawKey(keyName string, sessionState string, timeout int64) error {
func (r *RPCStorageHandler) SetRawKey(keyName, sessionState string, timeout int64) error {
return nil
}

Expand Down Expand Up @@ -527,7 +527,7 @@ func (r *RPCStorageHandler) StartPubSubHandler(channel string, callback func(red
return nil
}

func (r *RPCStorageHandler) Publish(channel string, message string) error {
func (r *RPCStorageHandler) Publish(channel, message string) error {
log.Warning("NO PUBSUB DEFINED")
return nil
}
Expand All @@ -538,7 +538,7 @@ func (r *RPCStorageHandler) GetAndDeleteSet(keyName string) []interface{} {
return []interface{}{}
}

func (r *RPCStorageHandler) AppendToSet(keyName string, value string) {
func (r *RPCStorageHandler) AppendToSet(keyName, value string) {

ibd := InboundData{
KeyName: keyName,
Expand Down Expand Up @@ -590,11 +590,11 @@ func (r RPCStorageHandler) GetSet(keyName string) (map[string]string, error) {
return map[string]string{}, nil
}

func (r RPCStorageHandler) AddToSet(keyName string, value string) {
func (r RPCStorageHandler) AddToSet(keyName, value string) {
log.Error("Not implemented")
}

func (r RPCStorageHandler) RemoveFromSet(keyName string, value string) {
func (r RPCStorageHandler) RemoveFromSet(keyName, value string) {
log.Error("Not implemented")
}

Expand Down Expand Up @@ -747,7 +747,7 @@ func (r *RPCStorageHandler) DeleteScanMatch(pattern string) bool {
func GetDispatcher() *gorpc.Dispatcher {
Dispatch := gorpc.NewDispatcher()

Dispatch.AddFunc("Login", func(clientAddr string, userKey string) bool {
Dispatch.AddFunc("Login", func(clientAddr, userKey string) bool {
return false
})

Expand Down Expand Up @@ -819,11 +819,11 @@ func GetDispatcher() *gorpc.Dispatcher {
return nil
})

Dispatch.AddFunc("CheckReload", func(clientAddr string, orgId string) (bool, error) {
Dispatch.AddFunc("CheckReload", func(clientAddr, orgId string) (bool, error) {
return false, nil
})

Dispatch.AddFunc("GetKeySpaceUpdate", func(clientAddr string, orgId string) ([]string, error) {
Dispatch.AddFunc("GetKeySpaceUpdate", func(clientAddr, orgId string) ([]string, error) {
return []string{}, nil
})

Expand Down

0 comments on commit 3f96ea4

Please sign in to comment.