ump-ngx

Check-in Differences
Login

Check-in Differences

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Difference From ump-ngx-0.0.1 To trunk

2024-09-10
04:31
Update swctx. Pedantic clippy work. Leaf check-in: 3fbd621354 user: jan tags: trunk
2024-08-07
09:55
Cleanup. check-in: 61bf725d2d user: jan tags: trunk, ump-ngx-0.0.1
09:00
Metadata fixes. check-in: ce59827538 user: jan tags: trunk

Changes to Cargo.toml.

1
2
3

4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30

31
32
33


34
35
36
37
38
1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31
32


33
34
35
36
37
38
39


-
+













+













-
+

-
-
+
+





[package]
name = "ump-ngx"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
license = "0BSD"
# https://crates.io/category_slugs
categories = [ "concurrency", "asynchronous" ]
keywords = [ "ump-ng", "message-passing" ]
repository = "https://repos.qrnch.tech/pub/ump-ngx"
description = "Collection of ump-ng extensions."
rust-version = "1.56"
exclude = [
  ".fossil-settings",
  ".efiles",
  ".fslckout",
  "www",
  "bacon.toml",
  "rustfmt.toml"
]

# https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section
[badges]
maintenance = { status = "experimental" }

[features]
#tokio = ["ump-ng-server/tokio"]
sqlsrv = ["dep:sqlsrv", "sqlsrv/tpool", "dep:threadpool"]

[dependencies]
sqlsrv = { version = "0.5.0", optional = true }
swctx = { version = "0.2.2" }
swctx = { version = "0.3.0" }
threadpool = { version = "1.8.1", optional = true }
ump-ng = { version = "0.1.0" }
ump-ng-server = { version = "0.3.0" }
ump-ng = { version = "0.2.0" }
ump-ng-server = { version = "0.4.0" }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]

Added bacon.toml.



































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# This is a configuration file for the bacon tool
#
# Bacon repository: https://github.com/Canop/bacon
# Complete help on configuration: https://dystroy.org/bacon/config/
# You can also check bacon's own bacon.toml file
#  as an example: https://github.com/Canop/bacon/blob/main/bacon.toml

# For information about clippy lints, see:
# https://github.com/rust-lang/rust-clippy/blob/master/README.md

#default_job = "check"
default_job = "clippy-all-pedantic"

[jobs.check]
command = ["cargo", "check", "--color", "always"]
need_stdout = false

[jobs.check-all]
command = ["cargo", "check", "--all-targets", "--color", "always"]
need_stdout = false

# Run clippy on the default target
[jobs.clippy]
command = [
    "cargo", "clippy",
    "--color", "always",
]
need_stdout = false

# Run clippy on all targets
# To disable some lints, you may change the job this way:
#    [jobs.clippy-all]
#    command = [
#        "cargo", "clippy",
#        "--all-targets",
#        "--color", "always",
#    	 "--",
#    	 "-A", "clippy::bool_to_int_with_if",
#    	 "-A", "clippy::collapsible_if",
#    	 "-A", "clippy::derive_partial_eq_without_eq",
#    ]
# need_stdout = false
[jobs.clippy-all]
command = [
    "cargo", "clippy",
    "--all-targets",
    "--color", "always",
]
need_stdout = false

[jobs.clippy-pedantic]
command = [
    "cargo", "clippy",
    "--color", "always",
    "--",
    "-Wclippy::all",
    "-Wclippy::pedantic",
    "-Wclippy::nursery",
    "-Wclippy::cargo"
]
need_stdout = false

[jobs.clippy-all-pedantic]
command = [
    "cargo", "clippy",
    "--all-targets",
    "--color", "always",
    "--",
    "-Wclippy::all",
    "-Wclippy::pedantic",
    "-Wclippy::nursery",
    "-Wclippy::cargo"
]
need_stdout = false

# This job lets you run
# - all tests: bacon test
# - a specific test: bacon test -- config::test_default_files
# - the tests of a package: bacon test -- -- -p config
[jobs.test]
command = [
    "cargo", "test", "--color", "always",
    "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124
]
need_stdout = true

[jobs.doc]
command = ["cargo", "doc", "--color", "always", "--no-deps"]
need_stdout = false

# If the doc compiles, then it opens in your browser and bacon switches
# to the previous job
[jobs.doc-open]
command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
need_stdout = false
on_success = "back" # so that we don't open the browser at each change

# You can run your application and have the result displayed in bacon,
# *if* it makes sense for this crate.
# Don't forget the `--color always` part or the errors won't be
# properly parsed.
# If your program never stops (eg a server), you may set `background`
# to false to have the cargo run output immediately displayed instead
# of waiting for program's end.
[jobs.run]
command = [
    "cargo", "run",
    "--color", "always",
    # put launch parameters for your program behind a `--` separator
]
need_stdout = true
allow_warnings = true
background = true

# This parameterized job runs the example of your choice, as soon
# as the code compiles.
# Call it as
#    bacon ex -- my-example
[jobs.ex]
command = ["cargo", "run", "--color", "always", "--example"]
need_stdout = true
allow_warnings = true

# You may define here keybindings that would be specific to
# a project, for example a shortcut to launch a specific job.
# Shortcuts to internal functions (scrolling, toggling, etc.)
# should go in your personal global prefs.toml file instead.
[keybindings]
# alt-m = "job:my-job"
c = "job:clippy-all" # comment this to have 'c' run clippy on only the default target

Added rustfmt.toml.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
blank_lines_upper_bound = 2
comment_width = 79
edition = "2021"
format_strings = true
max_width = 79
match_block_trailing_comma = false
# merge_imports = true
newline_style = "Unix"
tab_spaces = 2
trailing_comma = "Never"
unstable_features = true
wrap_comments = true
#reorder_imports = false
#reorder_modules = false

Changes to src/server/sqlsrv/utils.rs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1
2


3
4
5
6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40


-
-













-








-
+









-







//! Integration utilities for creating sqlsrv handlers.

use std::fmt;

use super::{r2d2, rusqlite, ConnPool, WrConn};

use rusqlite::Connection;

use threadpool::ThreadPool;

use ump_ng::ReplyContext;

pub enum Error<E> {
  R2D2(r2d2::Error),
  App(E)
}


/// Process a requested read-only database operation message.
pub fn proc_rodb_req<R, E, F>(
  cpool: &ConnPool,
  rctx: ReplyContext<R, E>,
  f: F
) -> Result<(), r2d2::Error>
where
  R: Send + 'static,
  E: fmt::Debug + Send + 'static,
  E: std::error::Error + Send + 'static,
  F: FnOnce(&Connection) -> Result<R, E> + Send + 'static
{
  let roconn = cpool.reader()?;

  let res = match f(&roconn) {
    Ok(reply) => rctx.reply(reply),
    Err(e) => rctx.fail(e)
  };
  if let Err(e) = res {
    // Note: This can currently not happen
    eprintln!("Reply message pass failed; {}", e);
  }

  Ok(())
}

/// Process a requested read-only database message on a thread pool.
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73

74
75
76
77

78
79
80
81
82
83
84
85
86
87

88
89
90

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123







-
+










-







-




-
+









-



-
















-
+










-






  cpool: &ConnPool,
  tpool: &ThreadPool,
  rctx: ReplyContext<R, E>,
  f: F
) -> Result<(), r2d2::Error>
where
  R: Send + 'static,
  E: fmt::Debug + Send + 'static,
  E: std::error::Error + Send + 'static,
  F: FnOnce(&Connection) -> Result<R, E> + Send + 'static
{
  let roconn = cpool.reader()?;

  tpool.execute(move || {
    let res = match f(&roconn) {
      Ok(reply) => rctx.reply(reply),
      Err(e) => rctx.fail(e)
    };
    if let Err(e) = res {
      // Note: This can currently not happen
      eprintln!("Reply message pass failed; {}", e);
    }
  });

  Ok(())
}


/// Process a requested read/write database message.
pub fn proc_rwdb_req<R, E, F>(cpool: &ConnPool, rctx: ReplyContext<R, E>, f: F)
where
  R: Send + 'static,
  E: fmt::Debug + Send + 'static,
  E: std::error::Error + Send + 'static,
  F: FnOnce(&mut WrConn) -> Result<R, E> + Send + 'static
{
  let mut conn = cpool.writer();

  let res = match f(&mut conn) {
    Ok(reply) => rctx.reply(reply),
    Err(e) => rctx.fail(e)
  };
  if let Err(e) = res {
    // Note: This can currently not happen
    eprintln!("Reply message pass failed; {}", e);
  }
}


/// Process a requested read/write database message on a thread pool.
///
/// The read/write database connection will be acquired from the connection
/// pool `cpool`.  The tread will be launched on the thread pool `tpool`.
///
/// The closure `f` returns a `Result<T, E>`, where the `Ok(T)` case will pass
/// the `T` to the `rctx`'s [`reply()`](ReplyContext::reply), and `Err(E)` will
/// pass the `E` to [`fail()`](ReplyContext::fail).
pub fn proc_rwdb_req_thrd<R, E, F>(
  cpool: &ConnPool,
  tpool: &ThreadPool,
  rctx: ReplyContext<R, E>,
  f: F
) where
  R: Send + 'static,
  E: fmt::Debug + Send + 'static,
  E: std::error::Error + Send + 'static,
  F: FnOnce(&mut WrConn) -> Result<R, E> + Send + 'static
{
  let mut rwconn = cpool.writer();

  tpool.execute(move || {
    let res = match f(&mut rwconn) {
      Ok(reply) => rctx.reply(reply),
      Err(e) => rctx.fail(e)
    };
    if let Err(e) = res {
      // Note: This can currently not happen
      eprintln!("Reply message pass failed; {}", e);
    }
  });
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :