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

refactor: app actor cleanup #2230

Merged
merged 2 commits into from Oct 3, 2022
Merged

refactor: app actor cleanup #2230

merged 2 commits into from Oct 3, 2022

Conversation

subotic
Copy link
Collaborator

@subotic subotic commented Oct 2, 2022

Issue Number: DEV-

Pull Request Checklist

Basic Requirements

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix: represents bug fixes
  • Refactor: represents production code refactoring
  • Feature: represents a new feature
  • Documentation: documentation changes (no production code change)
  • Chore: maintenance tasks (no production code change)
  • Style: styles updates (no production code change)
  • Test: all about tests: adding, refactoring tests (no production code change)
  • Other... Please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Does this PR change client-test-data?

  • Yes (don't forget to update the JS-LIB team about the change)
  • No

Other information

@subotic
Copy link
Collaborator Author

subotic commented Oct 2, 2022

Just some minor cleanup making the code (hopefully) simpler to read

@subotic subotic requested a review from mpro7 October 2, 2022 08:18
@codecov
Copy link

codecov bot commented Oct 2, 2022

Codecov Report

Base: 86.64% // Head: 86.85% // Increases project coverage by +0.21% 🎉

Coverage data is based on head (8811fc7) compared to base (71c772f).
Patch coverage: 84.52% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2230      +/-   ##
==========================================
+ Coverage   86.64%   86.85%   +0.21%     
==========================================
  Files         233      241       +8     
  Lines       28020    27970      -50     
==========================================
+ Hits        24277    24294      +17     
+ Misses       3743     3676      -67     
Impacted Files Coverage Δ
...sp-shared/src/main/scala/dsp/valueobjects/V2.scala 84.05% <0.00%> (-1.45%) ⬇️
webapi/src/main/scala/org/knora/webapi/Main.scala 0.00% <0.00%> (ø)
...n/responder/groupsmessages/GroupsMessagesADM.scala 73.33% <ø> (ø)
...sponder/projectsmessages/ProjectsMessagesADM.scala 91.19% <ø> (ø)
...tore/triplestoremessages/TriplestoreMessages.scala 74.78% <ø> (-0.22%) ⬇️
...webapi/messages/util/ConstructResponseUtilV2.scala 93.29% <ø> (ø)
...a/org/knora/webapi/messages/util/MessageUtil.scala 36.66% <ø> (ø)
...knora/webapi/messages/util/PermissionUtilADM.scala 84.54% <ø> (ø)
...vsearch/types/GravsearchTypeInspectionRunner.scala 100.00% <ø> (ø)
.../webapi/messages/v2/responder/KnoraRequestV2.scala 0.00% <ø> (ø)
... and 144 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@BalduinLandolt BalduinLandolt left a comment

Choose a reason for hiding this comment

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

note my comment on IIIF: not sure if we should use the stati WaitingForIIIF and IIIFReady in instances where no IIIF service is required

Comment on lines 96 to 107
for {
_ <- state.set(AppState.WaitingForIIIFService)
_ <- if (requiresIIIFService)
iiifs
.getStatus()
.flatMap(status =>
status match {
case IIIFServiceStatusOK =>
ZIO.logInfo("IIIF service running")
case IIIFServiceStatusNOK =>
ZIO.logError("IIIF service not running") *> ZIO.die(new Exception("IIIF service not running"))
}
)
else
ZIO.unit
_ <- iiifs
.getStatus()
.flatMap {
case IIIFServiceStatusOK =>
ZIO.logInfo("IIIF service running")
case IIIFServiceStatusNOK =>
ZIO.logError("IIIF service not running") *> ZIO.die(new Exception("IIIF service not running"))
}
.when(requiresIIIFService)
_ <- state.set(AppState.IIIFServiceReady)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm just wondering if it's actually reasonable to set the AppState to IIIF stuff, if we don't require the IIIF service. So maybe this method could be rewritten to:

private def checkIIIFService(requiresIIIFService: Boolean): ZIO[Any, Nothing, Unit] =
  if (requiresIIIFService) {
    for {
      _      <- state.set(AppState.WaitingForIIIFService)
      status <- iiifs.getStatus()
      _      <- status match {
        case CacheServiceStatusNOK =>
          ZIO.logError("Cache service not running.") *> 
            ZIO.die(new Exception("Cache service not running."))
        case CacheServiceStatusOK =>
          ZIO.unit
      }
      _      <- state.set(AppState.IIIFServiceReady)
    } yield ()
  } else ZIO.unit

optionally, you could also use ZIO.when to test the bool condition. And even ZIO.whenCase to check the status

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, good point. With ZIO I'm actually not sure if we need these states in such a detail at all, or if something waiting for startup is not good enough. Now that we have logging that works, we should quickly figure out where the startup is stuck. So I will merge it as is, and we can create a follow-up issue after we discuss it.

Copy link
Collaborator

@mpro7 mpro7 left a comment

Choose a reason for hiding this comment

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

Why the conditions (appConfig.allowReloadOverHttp and requiresIIIFService) were removed?

@subotic
Copy link
Collaborator Author

subotic commented Oct 3, 2022

Why the conditions (appConfig.allowReloadOverHttp and requiresIIIFService) were removed?

they are now checked inside when

@subotic subotic merged commit a67c98f into main Oct 3, 2022
@subotic subotic deleted the wip/app-actor-clenaup branch October 3, 2022 17:16
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

4 participants