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 Codable support for Context and unsafe add functionality #3

Merged
merged 5 commits into from
Jan 31, 2022

Conversation

Supereg
Copy link
Member

@Supereg Supereg commented Jan 31, 2022

Add Codable support for Context and unsafe add functionality

♻️ Current situation & Problem

Currently Context is not modifiable and Context is not encodable.

E.g. ApodiniMigrator has the use case to store gRPC related information within the Context of a TypeInformation. This requires:

  • Ability to modify the Context of a TypeInformation instance after it has been created as otherwise the only source for Context information are Metadata declaration blocks on Content types
  • Ability to encode and decode (if explicitly declared) ContextKeys

💡 Proposed solution

This PR adds a unsafeAdd method which can be used if appropriate. Further Context is made Codable, supporting lossy encoding and decoding of ContextKeys which declare conformance to CodableContextKey.

⚙️ Release Notes

  • Added new CodableContextKey for ContextKeys which Value support Codable.

➕ Additional Information

Related PRs

--

Testing

According tests were added.

Reviewer Nudging

--

Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #3 (03cdc0a) into develop (2f3f03f) will decrease coverage by 1.44%.
The diff coverage is 87.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop       #3      +/-   ##
===========================================
- Coverage    92.16%   90.73%   -1.43%     
===========================================
  Files           22       23       +1     
  Lines          395      485      +90     
===========================================
+ Hits           364      440      +76     
- Misses          31       45      +14     
Impacted Files Coverage Δ
Sources/ApodiniContext/ContextKey.swift 100.00% <ø> (ø)
Sources/ApodiniContext/CodableContextKey.swift 84.62% <84.62%> (ø)
Sources/ApodiniContext/Context.swift 87.63% <86.75%> (-12.37%) ⬇️
Sources/ApodiniContext/ContextEntry.swift 83.08% <100.00%> (ø)
Sources/ApodiniContext/ContextNode.swift 99.16% <100.00%> (-<0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f3f03f...03cdc0a. Read the comment docs.

@Supereg Supereg merged commit 7f0df17 into develop Jan 31, 2022
@Supereg Supereg deleted the feature/codable-support+unsafeadd branch January 31, 2022 22:07
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.

1 participant