• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kaicoh / serverless-rust-plugin / 6405951401

04 Oct 2023 12:27PM UTC coverage: 100.0%. Remained the same
6405951401

push

github

web-flow
Merge pull request #26 from jeffersd/fix-docker-argument-list

Fix docker build argument list

148 of 148 branches covered (100.0%)

Branch coverage included in aggregate %.

360 of 360 relevant lines covered (100.0%)

10.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/lambda.js
1
const http = require('http');
2✔
2

3
async function invoke(invokeOptions) {
4
  const {
5
    port,
6
    data,
7
    retryCount,
8
    retryInterval,
9
    stdout,
10
  } = invokeOptions;
11✔
11

12
  const body = JSON.stringify(data);
11✔
13

14
  const options = {
11✔
15
    hostname: 'localhost',
16
    port,
17
    path: '/2015-03-31/functions/function/invocations',
18
    method: 'POST',
19
  };
20

21
  return new Promise((resolve, reject) => {
11✔
22
    const req = http.request(options, (res) => {
11✔
23
      const response = {
7✔
24
        status: res.statusCode,
25
        headers: res.headers,
26
      };
27

28
      res.pipe(stdout ? process.stdout : process.stderr);
7✔
29

30
      res.on('error', reject);
7✔
31

32
      res.on('end', () => {
7✔
33
        if (!stdout) {
6✔
34
          // For readable output, insert some new lines to console.
35
          // If stdout is requested, we keep outputs untouched as much as possible.
36
          process.stderr.write('\n\n');
5✔
37
        }
38
        resolve(response);
6✔
39
      });
40
    });
41

42
    // NOTE:
43
    // If the request starts immediately after the docker container starts,
44
    // it will fail because the container is not ready to accept requests.
45
    // We have to retry in case of that.
46
    req.on('error', (err) => {
11✔
47
      if (retryCount === 0) {
4✔
48
        reject(err);
1✔
49
      }
50

51
      const retryOptions = {
4✔
52
        ...invokeOptions,
53
        retryCount: retryCount - 1,
54
      };
55

56
      setTimeout(() => {
4✔
57
        resolve(invoke(retryOptions));
3✔
58
      }, retryInterval);
59
    });
60

61
    req.write(body);
11✔
62
    req.end();
11✔
63
  });
64
}
65

66
module.exports = { invoke };
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc