profunktor / fs2-rabbit

:rabbit: RabbitMQ stream-based client built on top of Fs2
https://fs2-rabbit.profunktor.dev/
Apache License 2.0
149 stars 44 forks source link

Add headers type #956

Closed geirolz closed 2 months ago

geirolz commented 6 months ago

Here a recap of what's inside this PR:

❓Why so many files involved❓

🔄 Changes:

💥 Breaking changes:

Some examples:

import dev.profunktor.fs2rabbit.model.Headers

val headers = Headers(
      "x-custom-header"   := "value", // StringVal
      "x-custom-header-2" := 123 // IntVal
)
.updated("x-custom-header-3", 123L) // LongVal
.remove("x-custom-header-3")

/**
* OR
*   val headers = Headers(
*    "x-custom-header" -> StringVal("value"),
*    "x-custom-header-2" -> IntVal(123)
*   )
*   .updated("x-custom-header-3", LongVal(123L))
*   .remove("x-custom-header-3")
* */

headers.get[IO]("x-custom-header") // IO(StringVal("value"))
headers.getOpt("x-custom-header") // Some(StringVal("value"))

headers.getAs[IO, String]("x-custom-header") // IO("value")
headers.getOptAs[String]("x-custom-header") // Some("value")
headers.getOptAsF[IO, Int]("x-custom-header-2") // IO(Some(123))
matejcerny commented 5 months ago

Quite big, not sure if I have time soon for it 😞

geirolz commented 5 months ago

Quite big, not sure if I have time soon for it 😞

Np, let's release now and have a look to this when you have time. I've changed a lot but I introduced just one braking change, AmqpProperties now wants an instance of Headers instead of Map. I'll try to summarize all changes in the description in order to simplify the review

geirolz commented 5 months ago

@matejcerny I've updated the description. I hope it helps