mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-03 14:43:09 +00:00
fixing compilation errors
This commit is contained in:
parent
71a6d6f00b
commit
cff4062410
@ -5,13 +5,14 @@
|
||||
when defined(linux):
|
||||
{.passl: "-Wl,-soname,libsds.so".}
|
||||
|
||||
import std/[locks, typetraits, tables] # Added tables
|
||||
import std/[locks, typetraits, tables, atomics] # Added tables
|
||||
import chronos
|
||||
import results
|
||||
import
|
||||
./sds_thread/sds_thread,
|
||||
./alloc,
|
||||
./ffi_types,
|
||||
./sds_thread/inter_thread_communication/sds_thread_request,
|
||||
../src/[reliability, reliability_utils, message]
|
||||
|
||||
################################################################################
|
||||
|
||||
@ -2,6 +2,7 @@ import std/[options, json, strutils, net]
|
||||
import chronos, chronicles, results, confutils, confutils/std/net
|
||||
|
||||
import ../../../alloc
|
||||
import ../../../../src/[reliability_utils, reliability, message]
|
||||
|
||||
type SdsLifecycleMsgType* = enum
|
||||
CREATE_RELIABILITY_MANAGER
|
||||
@ -11,7 +12,7 @@ type SdsLifecycleRequest* = object
|
||||
channelId: cstring
|
||||
|
||||
proc createShared*(
|
||||
T: type SdsLifecycleRequest, op: SdsLifecycleMsgType, configJson: cstring = ""
|
||||
T: type SdsLifecycleRequest, op: SdsLifecycleMsgType, channelId: cstring = ""
|
||||
): ptr type T =
|
||||
var ret = createShared(T)
|
||||
ret[].operation = op
|
||||
@ -22,7 +23,9 @@ proc destroyShared(self: ptr SdsLifecycleRequest) =
|
||||
deallocShared(self[].channelId)
|
||||
deallocShared(self)
|
||||
|
||||
proc createReliabilityManager(channelId: cstring): Result[ReliabilityManager, string] =
|
||||
proc createReliabilityManager(
|
||||
channelIdCStr: cstring
|
||||
): Future[Result[ReliabilityManager, string]] {.async.} =
|
||||
let channelId = $channelIdCStr
|
||||
if channelId.len == 0:
|
||||
error "Failed creating ReliabilityManager: Channel ID cannot be empty"
|
||||
@ -32,14 +35,15 @@ proc createReliabilityManager(channelId: cstring): Result[ReliabilityManager, st
|
||||
error "Failed creating reliability manager", error = error
|
||||
return err("Failed creating reliability manager: " & $error)
|
||||
|
||||
rm.onMessageReady = proc(msgId: MessageID) =
|
||||
# TODO: instead of this, create events
|
||||
#[ rm.onMessageReady = proc(msgId: MessageID) =
|
||||
nimMessageReadyCallback(rm, msgId)
|
||||
rm.onMessageSent = proc(msgId: MessageID) =
|
||||
nimMessageSentCallback(rm, msgId)
|
||||
rm.onMissingDependencies = proc(msgId: MessageID, deps: seq[MessageID]) =
|
||||
nimMissingDependenciesCallback(rm, msgId, deps)
|
||||
rm.onPeriodicSync = proc() =
|
||||
nimPeriodicSyncCallback(rm)
|
||||
nimPeriodicSyncCallback(rm) ]#
|
||||
|
||||
return ok(rm)
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
|
||||
import std/json, results
|
||||
import chronos, chronos/threadsync
|
||||
import ../../ffi_types, ./requests/sds_lifecycle_request
|
||||
import
|
||||
../../ffi_types, ./requests/sds_lifecycle_request, ../../../src/[reliability_utils]
|
||||
|
||||
type RequestType* {.pure.} = enum
|
||||
LIFECYCLE
|
||||
|
||||
@ -4,7 +4,10 @@
|
||||
|
||||
import std/[options, atomics, os, net, locks]
|
||||
import chronicles, chronos, chronos/threadsync, taskpools/channels_spsc_single, results
|
||||
import ../ffi_types
|
||||
import
|
||||
../ffi_types,
|
||||
./inter_thread_communication/sds_thread_request,
|
||||
../../src/[reliability_utils]
|
||||
|
||||
type SdsContext* = object
|
||||
thread: Thread[(ptr SdsContext)]
|
||||
|
||||
@ -51,7 +51,7 @@ proc defaultConfig*(): ReliabilityConfig =
|
||||
resendInterval: DefaultResendInterval,
|
||||
maxResendAttempts: DefaultMaxResendAttempts,
|
||||
syncMessageInterval: DefaultSyncMessageInterval,
|
||||
bufferSweepInterval: DefaultBufferSweepInterval
|
||||
bufferSweepInterval: DefaultBufferSweepInterval,
|
||||
)
|
||||
|
||||
proc cleanup*(rm: ReliabilityManager) {.raises: [].} =
|
||||
@ -76,7 +76,9 @@ proc addToHistory*(rm: ReliabilityManager, msgId: MessageID) {.gcsafe, raises: [
|
||||
if rm.messageHistory.len > rm.config.maxMessageHistory:
|
||||
rm.messageHistory.delete(0)
|
||||
|
||||
proc updateLamportTimestamp*(rm: ReliabilityManager, msgTs: int64) {.gcsafe, raises: [].} =
|
||||
proc updateLamportTimestamp*(
|
||||
rm: ReliabilityManager, msgTs: int64
|
||||
) {.gcsafe, raises: [].} =
|
||||
rm.lamportTimestamp = max(msgTs, rm.lamportTimestamp) + 1
|
||||
|
||||
proc getRecentMessageIDs*(rm: ReliabilityManager, n: int): seq[MessageID] =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user