Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/valgrind-async-disaptch-threadpool-failure #10

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: boat
name: boat-ci
on:
push:
branches: [develop, deploy]
Expand Down
Binary file modified ADRs/boat_adr-ctas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ADRs/boat_adr-transports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ADRs/boat_adr.drawio

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--define:nimStrictDelete
--define:ssl
--define:threadsafe
--define:useMalloc
--hints:on
--mm:orc
--multimethods:on
Expand Down
5 changes: 1 addition & 4 deletions src/boat/private/Config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import std/[
strutils,
]

# TODO: simply importing FileManager causes valgrind to throw
# ^ weird cuz nothing is in there but stubs
import BoatErrors, BoatConstants

import BoatErrors, BoatConstants, FileManager

type Config* = ref object of RootObj
use*: string ## \
Expand Down
98 changes: 51 additions & 47 deletions src/boat/private/FileManager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,59 @@
## ===========
## Saving to and Retrieving from disk

import ../../../bdd
# valgrind throws if this file is imported into any other file
import std/asyncdispatch # causes valgrind to throw
import std/threadpool # causes valgrind to throw

import std/[
asyncdispatch,
locks,
threadpool,
]
# import ../../../bdd

import BoatConstants, BoatErrors
# import std/[
# asyncdispatch,
# locks,
# threadpool,
# ]

# import BoatConstants, BoatErrors

# export asyncdispatch

type SaveType* = enum
parsedConfig,
upsertManifest,
remoteManifest,

proc fileDir*(self: SaveType): string =
result = case self
of parsedConfig, upsertManifest: cacheDir
else: tempDir

proc toDisk*[T](
self: SaveType,
fname: string,
data: T,
): Future[string] {.async.} =
## persists data to cache or temp dir and returns path
## if file already exists, will overwrite if content is different
raise tddError
# file exists ?
# content is same? return true
# persist data
# lock
# save as self.fileDir / hash(fname)
# unlock
# return success
result = true

proc fromDisk*[T](
self: SaveType,
fname: string,
to: T,
errorNotFound = false
): Future[T] {.async.} =
## parse to T and return T
## throws if errorNotFound is true; else returns empty T
raise tddError
# yield readAsync self.fileDir / hash(fname)
# if file not found / cant be read then throw if errorNotFound is true
if errorNotFound and "cant load file" is string: raise fileLoadError
else: result = new(to)
# type SaveType* = enum
# parsedConfig,
# upsertManifest,
# remoteManifest,

# proc fileDir*(self: SaveType): string =
# result = case self
# of parsedConfig, upsertManifest: cacheDir
# else: tempDir

# proc toDisk*[T](
# self: SaveType,
# fname: string,
# data: T,
# ): Future[string] {.async.} =
# ## persists data to cache or temp dir and returns path
# ## if file already exists, will overwrite if content is different
# raise tddError
# # file exists ?
# # content is same? return true
# # persist data
# # lock
# # save as self.fileDir / hash(fname)
# # unlock
# # return success
# result = true

# proc fromDisk*[T](
# self: SaveType,
# fname: string,
# to: T,
# errorNotFound = false
# ): Future[T] {.async.} =
# ## parse to T and return T
# ## throws if errorNotFound is true; else returns empty T
# raise tddError
# # yield readAsync self.fileDir / hash(fname)
# # if file not found / cant be read then throw if errorNotFound is true
# if errorNotFound and "cant load file" is string: raise fileLoadError
# else: result = new(to)
80 changes: 63 additions & 17 deletions src/boat/private/captain/manifest.nim.ini
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
; FYI
; 0 = false, 1 = true
; standard options expected by boat
; entities can define additional and/or override existing options


; captains section
; each line represents an A, B or C to load
; A. dir path containing a `manifest.nim.ini`
; B. file path pointing to `manifest.nim.ini`
; C. a URL pointing to a `manifest.nim.ini`
[captains]
; TODO: confirm $HOME can be parsed to absolute path
; ^ FYI: $HOME wont be available for accounts without a $HOME dir (e.g. some sys accounts)
; ^^ supporting these accounts will likely increase scope
; ^^ check implementation of nimlangs getHomeDir() which may have already solved this problem
; ^^^ else move this to a post-alpha issue on the project board
$HOME/boat


; globals section
; arbitrary constraints and requirements
; affects boat globally
[globals]
raiseManifestNotFound=0 ; e.g. during config.load()
autoLoadSavedConfs=1 ; will load any previously saved confs from disk
; come back later


; affects all logging operations
[logger]
; come back later


; default config options, affects all config types
; prefer overriding options via a config type section
; captainslog, gunner, manifest, vessel,
[config]
; come back later


[captainslog]
; come back later


[gunner]
; come back later


[manifest]
captain=$HOME/boat


[vessel]
; come back later


; default script options, affects all script types
; prefer to override options via a script type
; duty, transport
[script]
; come back later


[duty]
; come back later


[transport]
; come back later


; default workflow options, affects all workflow types
; prefer to override options via a workflow type
; deck, pipeline
[workflow]
; come back later


[deck]
; come back later


[pipeline]
; come back later
Loading