slashmo / gsoc-swift-baggage-context

BaggageContext library, extracted from slashmo/gsoc-swift-tracing
https://github.com/slashmo/gsoc-swift-tracing
Apache License 2.0
4 stars 2 forks source link

Protocol to enable passing "context: CarriesBaggageContext" #7

Closed ktoso closed 3 years ago

ktoso commented 4 years ago

Goals:

What if we did

// in module Baggage
// so you'd `import Baggage`

protocol ContextCarrier { 
  var baggage: Context { get set }

  subscript<Key: ContextKey>(_ key: Key.Type) -> Key.Value? { get set }
}

struct Context { ... }

extension Context: ContextCarrier { 
  var baggage = self ... 
  ... 
}

This way other libs can:

We do have disambiguation that it's the Baggage.Context is any other lib has a Context type and they'd clash.

For passing around:

Let's explore this idea a bit ๐Ÿ‘€

ktoso commented 4 years ago

Moving this to the context repository

ktoso commented 4 years ago

cc @tomerd @tachyonics so that's a ticket from a while ago about the protocol libs could use. Other ideas and names and shapes quite welcome :)

ktoso commented 4 years ago

We could offer one which handles the logging bridge magic as separate module.

I'll be looking into this