Skip to content

Commit

Permalink
readme: fixes + todos
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Nov 28, 2023
1 parent e89407d commit 64b57a9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Drawing inspiration from [ZIO](https://zio.dev/)'s [effect rotation](https://deg

## Please visit https://getkyo.io for an indexed version of this documentation.

### Getting Started

TODO

### The `>` type

In Kyo, computations are expressed via the infix type `>`, which takes two parameters:
Expand Down Expand Up @@ -814,24 +818,29 @@ The module [`kyo-stats-otel`](https://central.sonatype.com/artifact/io.getkyo/ky
```scala
import kyo.stats._

// Initialize a Stats instance
// for a scope path
val stats: Stats =
Stats.initScope("my_application", "my_module")

// Initialize a counter
val a: Counter =
Stats.initCounter("my_counter")
stats.initCounter("my_counter")

// It's also possible to provide
// metadata when initializing
val b: Histogram =
Stats.initHistogram(
name = "my_histogram"
description = "some description"
stats.initHistogram(
name = "my_histogram",
description = "some description",
unit = "some unit",
attributes = Attributes.of("key", "value")
)

// Gauges take a function to be
// observed periodically
// Gauges take a by-name function to
// be observed periodically
val c: Gauge =
Stats.initGauge("free_memory") {
stats.initGauge("free_memory") {
Runtime.getRuntime().freeMemory()
}

Expand All @@ -853,7 +862,7 @@ val a: Int > IOs =
// Trace the execution of the
// `a` example computation
val b: Int > IOs =
Stats.traceSpan("my_span")(a)
stats.traceSpan("my_span")(a)
```

## Concurrent Effects
Expand Down Expand Up @@ -1544,10 +1553,20 @@ val d: String > Fibers =
Requests.run(backend)(a)
```

Please refer to Sttp's documentation for details on how to build requests.
Please refer to Sttp's documentation for details on how to build requests. Streaming is currently unsupported.

Users are free to use any JSON libraries supported by Sttp; however, [zio-json](https://github.com/zio/zio-json) is recommended, as it is used in Kyo's tests and modules requiring HTTP communication, such as `AIs``.

### Routes: HTTP Server via Tapir

TODO

### AIs: Large Language Models

TODO

## Restrictions

### Recursive Computations

Kyo evaluates pure computations strictly, without the need for suspensions or extra memory allocations. This approach enhances performance but requires careful handling of recursive computations to maintain stack safety.
Expand Down Expand Up @@ -1665,6 +1684,10 @@ val a: Int > Options =
// Possible pending effects mismatch: Expected 'kyo.concurrent.fibers.Fibers', found 'kyo.options.Options'.
```

## Performance Benchmarks

TODO

## Acknowledgements

Kyo's development was originally inspired by the paper ["Do Be Do Be Do"](https://arxiv.org/pdf/1611.09259.pdf) and its implementation in the [Unison](https://www.unison-lang.org/learn/language-reference/abilities-and-ability-handlers/) programming language. Kyo's design evolved from using interfaces for effects to using concrete values with tagged effect types, making it more efficient when executed on the JVM.
Expand Down
2 changes: 1 addition & 1 deletion kyo-core/shared/src/main/scala/kyo/stats/Stats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ object Stats {
traceReceiver.let(TraceReceiver.all(List(curr, receiver)))(v)
}

def scope(first: String, rest: String*): Stats =
def initScope(first: String, rest: String*): Stats =
scope(first :: rest.toList)

private def scope(path: List[String]): Stats =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class StatsTest extends KyoTest {
}

"scope" in {
val stats = Stats.scope("test")
val stats = Stats.initScope("test")
assert(stats.initCounter("a") == Counter.noop)
assert(stats.initHistogram("a") == Histogram.noop)
assert(stats.initGauge("a")(1) == Gauge.noop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import io.opentelemetry.sdk.OpenTelemetrySdkBuilder
class OTelReceiverTest extends KyoTest {

"metrics" in run {
val stats = Stats.scope("test")
val stats = Stats.initScope("test")
val counter = stats.initCounter("a")
val histogram = stats.initHistogram("b")
stats.initGauge("c")(99d)
Expand All @@ -33,7 +33,7 @@ class OTelReceiverTest extends KyoTest {
}

"traces" in run {
val stats = Stats.scope("test")
val stats = Stats.initScope("test")
stats.traceSpan("tspan") {
42d
}.map { r =>
Expand Down

0 comments on commit 64b57a9

Please sign in to comment.