• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #728

21 Oct 2025 09:16AM UTC coverage: 76.144% (-2.2%) from 78.302%
#728

Pull #113

github

sceredi
feat: add rewards management to rl controller
Pull Request #113: feat: create reinforcement learning controller

139 of 233 new or added lines in 22 files covered. (59.66%)

6 existing lines in 3 files now uncovered.

1497 of 1966 relevant lines covered (76.14%)

8.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/io/github/srs/controller/protobuf/rl/RLServerModule.scala
1
package io.github.srs.controller.protobuf.rl
2

3
import cats.effect.IO
4
import io.github.srs.model.ModelModule
5
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder
6
import io.github.srs.protos.rl.RLFs2Grpc
7
import com.typesafe.scalalogging.Logger
8

9
/**
10
 * Small module that runs a gRPC server for the RL service.
11
 */
12
object RLServerModule:
NEW
13

×
14
  /**
15
   * Represents a server that can be started. The `run` method returns an IO that never completes when the server is
16
   * running (conventional for long- lived servers in effectful applications).
17
   */
18
  trait Server:
NEW
19
    def run: IO[Unit]
×
20

21
  /**
22
   * Provider exposing a ready-to-run `Server` instance.
23
   */
24
  trait Provider:
25
    val server: Server
26

27
  /**
28
   * This module depends on an RL service provider so it can bind the generated gRPC implementation into the running
29
   * server.
30
   */
31
  type Requirements[S <: ModelModule.BaseState] = RLServiceModule.Provider
32

33
  /**
34
   * Component that constructs a `Server` given a port. The implementation builds a Netty server and binds the provided
35
   * RL service.
36
   */
37
  trait Component[S <: ModelModule.BaseState]:
NEW
38
    context: Requirements[S] =>
×
39

40
    object Server:
NEW
41
      /**
×
42
       * Create a server that listens on the provided port.
43
       *
44
       * @param port
45
       *   port to bind the server to
46
       * @return
47
       *   a `Server` instance
48
       */
49
      def apply(port: Int): Server = new ServerImpl(port)
NEW
50

×
51
      private class ServerImpl(port: Int) extends Server:
NEW
52
        private val logger = Logger(getClass.getName)
×
NEW
53

×
54
        /**
55
         * Run the server. The returned IO will start the Netty server and never complete (IO.never) while the server is
56
         * active. The service is obtained from the `context` (the RLService provider).
57
         */
58
        override def run: IO[Unit] =
59
          for
60
            service <- RLFs2Grpc.bindServiceResource(context.service).allocated
NEW
61
            (svc, _) = service
×
62
            server = NettyServerBuilder.forPort(port).addService(svc).build()
63
            _ <- IO(logger.debug("Starting RL server")) *> IO(server.start()) *> IO.never
NEW
64
          yield ()
×
NEW
65

×
66
    end Server
67

68
  end Component
69

70
  trait Interface[S <: ModelModule.BaseState] extends Provider with Component[S]:
71
    self: Requirements[S] =>
72

73
end RLServerModule
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc