question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatter should be static

See original GitHub issue

I noticed the formatter lives within the CloudEvent object.

CloudEvent {
  spec:
   Spec1 {
     payload:
      { specversion: '1.0',
        id: '1234',
        time: '2020-05-28T20:46:18.970Z',
        source: '/some/source',
        type: 'example',
        datacontenttype: undefined,
        data: undefined,
        subject: undefined } },
  formatter: JSONFormatter {},
  extensions: [] }

This doesn’t really make sense since we can have 1000 CloudEvent objects with the same formatter.

Maybe it should be a static class/set of methods.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lancecommented, May 29, 2020

I was thinking actually of removing it entirely from the class, along with the format() function. Instead, expose a top level Formatter class or formatter() function that takes a CloudEvent and formats it as JSON by default. But of course that would be a breaking change and require a version bump. Making it static is a good first step.

0reactions
lholmquistcommented, Jun 18, 2020

Probably going to hold off on this since it will be part of #226

should we close?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I create only one static instance of DateTimeFormatter
Yes, it is possible. Your variable is Thread Safe because it is immutable - No other thread can change it. Other solutions are...
Read more >
DateTimeFormatter (Java Platform SE 8 ) - Oracle Help Center
Gets the overriding zone to be used during formatting. static DateTimeFormatter · ofLocalizedDate(FormatStyle dateStyle). Returns a locale specific date format ...
Read more >
Shared API for package java.time.format - Elastic
See the Shared API for a high-level overview of all packages and classes. DateTimeFormatteredit. static DateTimeFormatter BASIC_ISO_DATE; static ...
Read more >
How to use DateFormatter in Swift - Sarunw
Since both creating and updating DateFormatter are expensive, we create a static DateFormatter for every possible style in our app here.
Read more >
DateFormatConstant - Error Prone
4 requires CONSTANT_CASE to only be used for static final fields whose contents are deeply immutable and whose methods have no detectable side...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found