Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- type family FedApi (comp :: Component) = (api :: Type) | api -> comp
- type HasFedEndpoint comp api name = HasUnsafeFedEndpoint comp api name
- type HasUnsafeFedEndpoint comp api name = 'Just api ~ LookupEndpoint (FedApi comp) name
- class FederationMonad (fedM :: Component -> Type -> Type) where
- fedClientWithProxy :: forall (comp :: Component) name api. (HasClient (fedM comp) api, HasFedEndpoint comp api name, KnownComponent comp, IsNamed name, Typeable (Client (fedM comp) api)) => Proxy name -> Proxy api -> Proxy (fedM comp) -> Client (fedM comp) api
- class IsNamed (name :: k) where
- nameVal :: forall {k} (name :: k). IsNamed name => Text
- fedClient :: forall (comp :: Component) name fedM (showcomp :: Symbol) api x. (AddAnnotation 'Remote showcomp (FedPath name) x, showcomp ~ ShowComponent comp, HasFedEndpoint comp api name, HasClient (fedM comp) api, KnownComponent comp, IsNamed name, FederationMonad fedM, Typeable (Client (fedM comp) api)) => Client (fedM comp) api
- fedQueueClient :: forall {k} (tag :: k) c. (HasNotificationEndpoint tag, HasVersionRange tag, HasFedPath tag, KnownComponent (NotificationComponent k), ToJSON (Payload tag), c ~ NotificationComponent k) => Payload tag -> FedQueueClient c ()
- sendBundle :: KnownComponent c => PayloadBundle c -> FedQueueClient c ()
- fedClientIn :: forall (comp :: Component) (name :: Symbol) m api. (HasFedEndpoint comp api name, HasClient m api) => Client m api
- data Annotation
- class AddAnnotation (loc :: Location) (api :: Symbol) (method :: Symbol) a
- class HasFeds (a :: k) where
- getFedCalls :: Proxy a -> State FedCallFrom [FedCallFrom]
- newtype Calls = Calls {}
- data FedCallFrom' (f :: Type -> Type) = FedCallFrom {}
- type family ShowComponent (x :: Component) = (res :: Symbol) | res -> x where ...
- data MakesFederatedCall (comp :: Component) (name :: Symbol)
- type CallsFed (comp :: Component) = HasAnnotation 'Remote (ShowComponent comp)
- data Component
- exposeAnnotations :: ToHasAnnotations x => a -> a
- callsFed :: SolveCallsFed c r a => (c => r) -> a
- data Component
- makeConversationUpdateBundle :: ConversationUpdate -> FedQueueClient 'Galley (PayloadBundle 'Galley)
Documentation
type HasFedEndpoint comp api name = HasUnsafeFedEndpoint comp api name Source #
type HasUnsafeFedEndpoint comp api name = 'Just api ~ LookupEndpoint (FedApi comp) name Source #
Like HasFedEndpoint
, but doesn't propagate a CallsFed
constraint.
Useful for tests, but unsafe in the sense that incorrect usage will allow
you to forget about some federated calls.
class FederationMonad (fedM :: Component -> Type -> Type) where Source #
fedClientWithProxy :: forall (comp :: Component) name api. (HasClient (fedM comp) api, HasFedEndpoint comp api name, KnownComponent comp, IsNamed name, Typeable (Client (fedM comp) api)) => Proxy name -> Proxy api -> Proxy (fedM comp) -> Client (fedM comp) api Source #
Instances
FederationMonad FederatorClient Source # | |
Defined in Wire.API.Federation.API fedClientWithProxy :: forall {k} (comp :: Component) (name :: k) api. (HasClient (FederatorClient comp) api, HasFedEndpoint comp api name, KnownComponent comp, IsNamed name, Typeable (Client (FederatorClient comp) api)) => Proxy name -> Proxy api -> Proxy (FederatorClient comp) -> Client (FederatorClient comp) api Source # |
fedClient :: forall (comp :: Component) name fedM (showcomp :: Symbol) api x. (AddAnnotation 'Remote showcomp (FedPath name) x, showcomp ~ ShowComponent comp, HasFedEndpoint comp api name, HasClient (fedM comp) api, KnownComponent comp, IsNamed name, FederationMonad fedM, Typeable (Client (fedM comp) api)) => Client (fedM comp) api Source #
Return a client for a named endpoint.
This function introduces an AddAnnotation
constraint, which is
automatically solved by the transitive-anns
plugin, and pushes the
resulting information around in a side-channel. See the documentation at
exposeAnnotations
for a better understanding
of the information flow here.
fedQueueClient :: forall {k} (tag :: k) c. (HasNotificationEndpoint tag, HasVersionRange tag, HasFedPath tag, KnownComponent (NotificationComponent k), ToJSON (Payload tag), c ~ NotificationComponent k) => Payload tag -> FedQueueClient c () Source #
sendBundle :: KnownComponent c => PayloadBundle c -> FedQueueClient c () Source #
fedClientIn :: forall (comp :: Component) (name :: Symbol) m api. (HasFedEndpoint comp api name, HasClient m api) => Client m api Source #
data Annotation Source #
Instances
class AddAnnotation (loc :: Location) (api :: Symbol) (method :: Symbol) a Source #
AddAnnotation
constraints are automatically solved by this plugin, but
internally act as "unsolved" constraints, without you needing to propagate
them by hand.
The unsolved constraints can be reintroduced via a ToHasAnnotations
constraint, which will automatically be solved and replaced with
a corresponding HasAnnotation
for every AddAnnotation
in the transitive
closure.
The a
parameter is intentionally ambiguous, existing as a unique skolem to
prevent GHC from caching the results of solving AddAnnotation
. Callers
needn't worry about it.
class HasFeds (a :: k) where Source #
getFedCalls :: Proxy a -> State FedCallFrom [FedCallFrom] Source #
Instances
data FedCallFrom' (f :: Type -> Type) Source #
Instances
Monoid FedCallFrom | |
Semigroup (FedCallFrom' Identity) | |
Defined in Wire.API.MakesFederatedCall (<>) :: FedCallFrom' Identity -> FedCallFrom' Identity -> FedCallFrom' Identity # sconcat :: NonEmpty (FedCallFrom' Identity) -> FedCallFrom' Identity # stimes :: Integral b => b -> FedCallFrom' Identity -> FedCallFrom' Identity # | |
Semigroup (FedCallFrom' Maybe) | |
Defined in Wire.API.MakesFederatedCall (<>) :: FedCallFrom' Maybe -> FedCallFrom' Maybe -> FedCallFrom' Maybe # sconcat :: NonEmpty (FedCallFrom' Maybe) -> FedCallFrom' Maybe # stimes :: Integral b => b -> FedCallFrom' Maybe -> FedCallFrom' Maybe # | |
Show (FedCallFrom' Identity) | |
Defined in Wire.API.MakesFederatedCall | |
Show (FedCallFrom' Maybe) | |
Defined in Wire.API.MakesFederatedCall |
type family ShowComponent (x :: Component) = (res :: Symbol) | res -> x where ... Source #
Get a symbol representation of our component.
ShowComponent 'Brig = "brig" | |
ShowComponent 'Galley = "galley" | |
ShowComponent 'Cargohold = "cargohold" |
data MakesFederatedCall (comp :: Component) (name :: Symbol) Source #
Servant combinator for tracking calls to federated calls. Annotating API
endpoints with MakesFederatedCall
is the only way to eliminate CallsFed
constraints on handlers.
Instances
type CallsFed (comp :: Component) = HasAnnotation 'Remote (ShowComponent comp) Source #
A typeclass corresponding to calls to federated services. This class has no methods, and exists only to automatically propagate information up to servant.
The only way to discharge this constraint is via callsFed
, which should be
invoked for each federated call when connecting handlers to the server
definition.
Instances
Arbitrary Component | |
FromJSON Component | |
ToJSON Component | |
Generic Component | |
Show Component | |
Eq Component | |
FromHttpApiData Component | |
Defined in Wire.API.MakesFederatedCall | |
ToHttpApiData Component | |
Defined in Wire.API.MakesFederatedCall toUrlPiece :: Component -> Text Source # toEncodedUrlPiece :: Component -> Builder Source # toHeader :: Component -> ByteString Source # toQueryParam :: Component -> Text Source # | |
ToSchema Component | |
Defined in Wire.API.MakesFederatedCall | |
type Rep Component | |
Defined in Wire.API.MakesFederatedCall type Rep Component = D1 ('MetaData "Component" "Wire.API.MakesFederatedCall" "wire-api-0.1.0-3915FetN8WgFcCGrbk6Vve" 'False) (C1 ('MetaCons "Brig" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Galley" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Cargohold" 'PrefixI 'False) (U1 :: Type -> Type))) |
exposeAnnotations :: ToHasAnnotations x => a -> a Source #
This function exists only to provide a convenient place for the
transitive-anns
plugin to solve the ToHasAnnotations
constraint. This is
highly magical and warrants a note.
The call
will expand to exposeAnnotations
(some expr here)some expr
here
, additionally generating wanted HasAnnotation
constraints for every
AddAnnotation
constraint in the _transitive call closure_ of some expr
here
.
The use case is always going to be
,
where callsFed
(exposeAnnotations
expr)exposeAnnotations
re-introduces all of the constraints we've been
squirreling away, and callsFed
is responsible for discharging them. It
would be very desirable to combine these into one call, but the semantics of
solving ToHasAnnotations
attaches the wanted calls to the same place as
the call itself, which means the wanteds appear just after our opportunity
to solve them via callsFed
. This is likely not a hard limitation.
The x
parameter here is intentionally ambiguous, existing as a unique
skolem to prevent GHC from caching the results of solving
ToHasAnnotations
. Callers needn't worry about it.
callsFed :: SolveCallsFed c r a => (c => r) -> a Source #
Safely discharge a CallsFed
constraint. Intended to be used when
connecting your handler to the server router.
This function should always be called with an argument of
exposeAnnotations
. See the documentation there for more information on
why.
Re-exports
Instances
Arbitrary Component | |
FromJSON Component | |
ToJSON Component | |
Generic Component | |
Show Component | |
Eq Component | |
FromHttpApiData Component | |
Defined in Wire.API.MakesFederatedCall | |
ToHttpApiData Component | |
Defined in Wire.API.MakesFederatedCall toUrlPiece :: Component -> Text Source # toEncodedUrlPiece :: Component -> Builder Source # toHeader :: Component -> ByteString Source # toQueryParam :: Component -> Text Source # | |
ToSchema Component | |
Defined in Wire.API.MakesFederatedCall | |
type Rep Component | |
Defined in Wire.API.MakesFederatedCall type Rep Component = D1 ('MetaData "Component" "Wire.API.MakesFederatedCall" "wire-api-0.1.0-3915FetN8WgFcCGrbk6Vve" 'False) (C1 ('MetaCons "Brig" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Galley" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Cargohold" 'PrefixI 'False) (U1 :: Type -> Type))) |