Skip to content

Commit

Permalink
Name update chore
Browse files Browse the repository at this point in the history
  • Loading branch information
kchiranjewee63 committed Jan 29, 2025
1 parent 6a36aa2 commit 6cb3865
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion service/common/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package common

const (
TRATTERIA_SERVICE_NAME = "tokenetes"
TOKENETES_SERVICE_NAME = "tokenetes"
)
4 changes: 2 additions & 2 deletions service/servicemessagehandler/servicemessagehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (smh *ServiceMessageHandler) DispatchTraTGenerationRule(ctx context.Context
return fmt.Errorf("error marshaling generation trat rule: %w", err)
}

err = smh.sendMessage(ctx, common.TRATTERIA_SERVICE_NAME, namespace, websocketserver.MessageTypeTraTGenerationRuleUpsertRequest, jsonData, verisionNumber)
err = smh.sendMessage(ctx, common.TOKENETES_SERVICE_NAME, namespace, websocketserver.MessageTypeTraTGenerationRuleUpsertRequest, jsonData, verisionNumber)
if err != nil {
return fmt.Errorf("error dispatching generation trat rule to tokenetes: %w", err)
}
Expand All @@ -135,7 +135,7 @@ func (smh *ServiceMessageHandler) DispatchTokenetesConfigGenerationRule(ctx cont
return fmt.Errorf("error marshaling generation tokenetes config rule: %w", err)
}

err = smh.sendMessage(ctx, common.TRATTERIA_SERVICE_NAME, namespace, websocketserver.MessageTypeTokenetesConfigGenerationRuleUpsertRequest, jsonData, versionNumber)
err = smh.sendMessage(ctx, common.TOKENETES_SERVICE_NAME, namespace, websocketserver.MessageTypeTokenetesConfigGenerationRuleUpsertRequest, jsonData, versionNumber)
if err != nil {
return fmt.Errorf("error dispatching generation tokenetes config rule to tokenetes: %w", err)
}
Expand Down
12 changes: 6 additions & 6 deletions service/tokenetescontroller/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,16 @@ func (c *Controller) GetActiveGenerationRules(namespace string) (*tokenetes1alph
}

func (c *Controller) GetActiveGenerationRulesHash(namespace string) (string, int64, error) {
err := c.RecomputeRulesHashesIfNotLatest(common.TRATTERIA_SERVICE_NAME, namespace)
err := c.RecomputeRulesHashesIfNotLatest(common.TOKENETES_SERVICE_NAME, namespace)
if err != nil {
return "", 0, err
}

c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TRATTERIA_SERVICE_NAME].mu.RLock()
defer c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TRATTERIA_SERVICE_NAME].mu.RUnlock()
c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TOKENETES_SERVICE_NAME].mu.RLock()
defer c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TOKENETES_SERVICE_NAME].mu.RUnlock()

return c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TRATTERIA_SERVICE_NAME].hash,
c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TRATTERIA_SERVICE_NAME].ruleVersionNumber,
return c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TOKENETES_SERVICE_NAME].hash,
c.allRulesHashes.namespacesRulesHashes[namespace].servicesRulesHashes[common.TOKENETES_SERVICE_NAME].ruleVersionNumber,
nil
}

Expand Down Expand Up @@ -559,7 +559,7 @@ func (c *Controller) RecomputeRulesHashesIfNotLatest(serviceName string, namespa
// The computed hash is guaranteed to incorporate changes at least up to and including this rule version number
ruleVersionNumber := atomic.LoadInt64(&c.ruleVersionNumber)

if serviceName == common.TRATTERIA_SERVICE_NAME {
if serviceName == common.TOKENETES_SERVICE_NAME {
activeGenerationRules, _, err := c.GetActiveGenerationRules(namespace)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion service/tokenetescontroller/controller/tratcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (c *Controller) handleTraTDeletion(ctx context.Context, oldTraT *tokenetes1
services[serviceSpec.Name] = true
}

services[common.TRATTERIA_SERVICE_NAME] = true
services[common.TOKENETES_SERVICE_NAME] = true

// TODO: Implement parallel requests using goroutines
for service := range services {
Expand Down
14 changes: 7 additions & 7 deletions service/websocketserver/clientmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const (
MessageTypeTraTVerificationRuleUpsertResponse MessageType = "TRAT_VERIFICATION_RULE_UPSERT_RESPONSE"
MessageTypeTraTGenerationRuleUpsertRequest MessageType = "TRAT_GENERATION_RULE_UPSERT_REQUEST"
MessageTypeTraTGenerationRuleUpsertResponse MessageType = "TRAT_GENERATION_RULE_UPSERT_RESPONSE"
MessageTypeTokenetesConfigVerificationRuleUpsertRequest MessageType = "TRATTERIA_CONFIG_VERIFICATION_RULE_UPSERT_REQUEST"
MessageTypeTokenetesConfigVerificationRuleUpsertResponse MessageType = "TRATTERIA_CONFIG_VERIFICATION_RULE_UPSERT_RESPONSE"
MessageTypeTokenetesConfigGenerationRuleUpsertRequest MessageType = "TRATTERIA_CONFIG_GENERATION_RULE_UPSERT_REQUEST"
MessageTypeTokenetesConfigGenerationRuleUpsertResponse MessageType = "TRATTERIA_CONFIG_GENERATION_RULE_UPSERT_RESPONSE"
MessageTypeTokenetesConfigVerificationRuleUpsertRequest MessageType = "TOKENETES_CONFIG_VERIFICATION_RULE_UPSERT_REQUEST"
MessageTypeTokenetesConfigVerificationRuleUpsertResponse MessageType = "TOKENETES_CONFIG_VERIFICATION_RULE_UPSERT_RESPONSE"
MessageTypeTokenetesConfigGenerationRuleUpsertRequest MessageType = "TOKENETES_CONFIG_GENERATION_RULE_UPSERT_REQUEST"
MessageTypeTokenetesConfigGenerationRuleUpsertResponse MessageType = "TOKENETES_CONFIG_GENERATION_RULE_UPSERT_RESPONSE"
MessageTypeRuleReconciliationRequest MessageType = "RULE_RECONCILIATION_REQUEST"
MessageTypeRuleReconciliationResponse MessageType = "RULE_RECONCILIATION_RESPONSE"
MessageTypeTraTDeletionRequest MessageType = "TRAT_DELETION_REQUEST"
Expand Down Expand Up @@ -184,7 +184,7 @@ func (cm *ClientManager) compareAndReconcileRule(appData string) {

var activeRuleVersionNumber int64

if cm.Service == common.TRATTERIA_SERVICE_NAME {
if cm.Service == common.TOKENETES_SERVICE_NAME {
lateshHash, activeRuleVersionNumber, _ = cm.Server.ruleRetriever.GetActiveGenerationRulesHash(cm.Namespace)
} else {
lateshHash, activeRuleVersionNumber, _ = cm.Server.ruleRetriever.GetActiveVerificationRulesHash(cm.Service, cm.Namespace)
Expand Down Expand Up @@ -215,7 +215,7 @@ func (cm *ClientManager) reconcileRules() error {

allActiveRulesPayload := &AllActiveRulesPayload{}

if cm.Service == common.TRATTERIA_SERVICE_NAME {
if cm.Service == common.TOKENETES_SERVICE_NAME {
completeGenerationRules, activeRuleVersionNumber, err = cm.Server.ruleRetriever.GetActiveGenerationRules(cm.Namespace)
if err != nil {
cm.Server.Logger.Error("Error getting all active generation rules from controller", zap.Error(err))
Expand Down Expand Up @@ -342,7 +342,7 @@ func (cm *ClientManager) handleRequest(message []byte) {
}

func (cm *ClientManager) handleGetJWKSRequest(request Request) {
tokenetesInstances := cm.Server.GetClientManagers(common.TRATTERIA_SERVICE_NAME, cm.Namespace)
tokenetesInstances := cm.Server.GetClientManagers(common.TOKENETES_SERVICE_NAME, cm.Namespace)
if len(tokenetesInstances) == 0 {
cm.Server.Logger.Warn("No active tokenetes instances found", zap.String("namespace", cm.Namespace))
cm.sendErrorResponse(request.ID, MessageTypeGetJWKSResponse, http.StatusNotFound, "No active tokenetes instances found")
Expand Down
4 changes: 2 additions & 2 deletions service/websocketserver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (wss *WebSocketServer) handleWebSocket(w http.ResponseWriter, r *http.Reque

initialRulesPayload := &AllActiveRulesPayload{}

if serviceName == common.TRATTERIA_SERVICE_NAME {
if serviceName == common.TOKENETES_SERVICE_NAME {
activeGenerationRules, activeRuleVersionNumber, err = wss.ruleRetriever.GetActiveGenerationRules(namespace)
if err != nil {
wss.Logger.Error("Error getting initial generation rules from controller", zap.Error(err))
Expand Down Expand Up @@ -274,7 +274,7 @@ func (wss *WebSocketServer) GetTokenetesAgentServices(namespace string) []string
var tokenetesAgentsServices []string

for service := range wss.ClientManagers {
if service != common.TRATTERIA_SERVICE_NAME {
if service != common.TOKENETES_SERVICE_NAME {
tokenetesAgentsServices = append(tokenetesAgentsServices, service)
}
}
Expand Down

0 comments on commit 6cb3865

Please sign in to comment.