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

Add VcrStorage abstraction #23

Merged
merged 6 commits into from
Apr 11, 2021
Merged

Add VcrStorage abstraction #23

merged 6 commits into from
Apr 11, 2021

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Apr 11, 2021

Closes #22

This PR introduces VcrStorage abstraction.
The trait abstract "reading record from somewhere" and "writing record to somewhere".

Codec trait is also introduced.
It abstract how VcrEntries is

  • encoded from JSON, YAML or whatever, and
  • decoded to JSON, YAML or whatever

This abstraction helps #3

@reibitto
Copy link
Owner

You're very quick with these 😂 Thanks!

I only noticed now, but it seems like the java: [11, 8] matrix in the the GitHub Actions workflow is not doing what was intended. Even the one marked as 11 is actually using 8:

[info] welcome to sbt 1.5.0 (AdoptOpenJDK Java 1.8.0_275)

It might be because olafurpg/setup-scala@v10 does its own setup?

@exoego
Copy link
Contributor Author

exoego commented Apr 11, 2021

Ah, I will look into jdk setup issues

Comment on lines 28 to 29
def apply(recordingPath: Path): FileVcrStorage =
new FileVcrStorage(recordingPath, CirceCodec, StandardCharsets.UTF_8)
Copy link
Contributor Author

@exoego exoego Apr 11, 2021

Choose a reason for hiding this comment

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

Maybe implicit parameter is better to allow switching format (codec) to YAML or other?

  def apply(recordingPath: Path)(implicit codec: Codec): FileVcrStorage =
    new FileVcrStorage(recordingPath, codec, StandardCharsets.UTF_8)

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure if it needs to be implicit. Maybe even default parameters (default of json) could work? I know some people don't like default parameters, but I'm already using them in the clients.

Also, maybe CirceCodec should be renamed to JsonCodec? Because circe also has a yaml library (https://github.com/circe/circe-yaml), which I imagine would be natural to use in this library. So we'd also have a YamlCodec in the future, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to JsonCodec 7698613
And introduced default parameters 48c9df0

Copy link
Owner

@reibitto reibitto left a comment

Choose a reason for hiding this comment

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

Thank you. This looks good to me.

I think I can release the first version of this library tomorrow. I just need to update all the examples, add more scaladocs, and then add a few more tests.

@reibitto reibitto merged commit 1d82f73 into reibitto:master Apr 11, 2021
@exoego exoego deleted the storage branch April 11, 2021 12:13
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.

Add VcrStorage abstraction
2 participants