Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move Q specific functions to Q package and remove noisy logs #4741

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua commented Jul 30, 2024

These 2 functions are invoked quite frequently and hence spamming the logs and the log entry doens't provide much useful info

fun isQConnected(project: Project): Boolean {
    val manager = ToolkitConnectionManager.getInstance(project)
    val qState = manager.connectionStateForFeature(QConnection.getInstance())
    val cwState = manager.connectionStateForFeature(CodeWhispererConnection.getInstance())
    LOG.debug {
        "qConnectionState: $qState; cwConnectionState: $cwState"
    }
    return qState != BearerTokenAuthState.NOT_AUTHENTICATED && cwState != BearerTokenAuthState.NOT_AUTHENTICATED
}

fun isQExpired(project: Project): Boolean {
    val manager = ToolkitConnectionManager.getInstance(project)
    val qState = manager.connectionStateForFeature(QConnection.getInstance())
    val cwState = manager.connectionStateForFeature(CodeWhispererConnection.getInstance())
    LOG.debug {
        "qConnectionState: $qState; cwConnectionState: $cwState"
    }
    return qState == BearerTokenAuthState.NEEDS_REFRESH || cwState == BearerTokenAuthState.NEEDS_REFRESH
}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Will-ShaoHua Will-ShaoHua requested review from a team as code owners July 30, 2024 00:10
Comment on lines +16 to +18
val manager = ToolkitConnectionManager.getInstance(project)
val qState = manager.connectionStateForFeature(QConnection.getInstance())
val cwState = manager.connectionStateForFeature(CodeWhispererConnection.getInstance())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are duplicated, can we extract them to a separate function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants