summaryrefslogtreecommitdiff
path: root/src/Service.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-07-03 20:21:04 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-07-03 22:58:13 +0200
commitba636680dc5fdd7d5db81248e4fa737d026f985f (patch)
treed6ebbd6166d8974bb9ded012f660583de84be8f4 /src/Service.hs
parent4bed9f9d88f4ce57b540e756e3d26ed708078604 (diff)
Handle Sync service outside of Network module
Diffstat (limited to 'src/Service.hs')
-rw-r--r--src/Service.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Service.hs b/src/Service.hs
index 4fc8335..a3a19a4 100644
--- a/src/Service.hs
+++ b/src/Service.hs
@@ -3,6 +3,7 @@ module Service (
SomeService(..), someService, someServiceAttr, someServiceID,
SomeServiceState(..), fromServiceState, someServiceEmptyState,
SomeServiceGlobalState(..), fromServiceGlobalState, someServiceEmptyGlobalState,
+ SomeStorageWatcher(..),
ServiceID, mkServiceID,
ServiceHandler,
@@ -40,6 +41,9 @@ class (Typeable s, Storable s, Typeable (ServiceState s), Typeable (ServiceGloba
serviceID :: proxy s -> ServiceID
serviceHandler :: Stored s -> ServiceHandler s ()
+ serviceNewPeer :: ServiceHandler s ()
+ serviceNewPeer = return ()
+
type ServiceAttributes s = attr | attr -> s
type ServiceAttributes s = Proxy s
defaultServiceAttributes :: proxy s -> ServiceAttributes s
@@ -58,6 +62,9 @@ class (Typeable s, Storable s, Typeable (ServiceState s), Typeable (ServiceGloba
default emptyServiceGlobalState :: ServiceGlobalState s ~ () => proxy s -> ServiceGlobalState s
emptyServiceGlobalState _ = ()
+ serviceStorageWatchers :: proxy s -> [SomeStorageWatcher s]
+ serviceStorageWatchers _ = []
+
data SomeService = forall s. Service s => SomeService (Proxy s) (ServiceAttributes s)
@@ -87,6 +94,9 @@ someServiceEmptyGlobalState :: SomeService -> SomeServiceGlobalState
someServiceEmptyGlobalState (SomeService p _) = SomeServiceGlobalState p (emptyServiceGlobalState p)
+data SomeStorageWatcher s = forall a. Eq a => SomeStorageWatcher (Stored LocalState -> a) (a -> ServiceHandler s ())
+
+
newtype ServiceID = ServiceID UUID
deriving (Eq, Ord, StorableUUID)