Skip to content

Commit 68f836c

Browse files
authored
feat: batching api (#173)
1 parent 7fe9637 commit 68f836c

9 files changed

Lines changed: 1005 additions & 881 deletions

File tree

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,35 @@ https://sofie-automation.github.io/sofie-core//docs/for-developers/contribution-
44
-->
55

66
## About the Contributor
7+
78
<!--
89
Tell us who / which organization you are representing, and how the Sofie team will be able to contact you.
910
Example: "This pull request is posted on behalf of the NRK."
1011
-->
1112

12-
1313
## Type of Contribution
1414

1515
This is a:
16+
1617
<!-- (pick one) -->
17-
Bug fix / Feature / Code improvement / Documentation improvement / Other (please specify)
1818

19+
Bug fix / Feature / Code improvement / Documentation improvement / Other (please specify)
1920

2021
## Current Behavior
22+
2123
<!--
2224
Please describe how things worked before this PR.
2325
If it's a bug fixe: Describe the bug (what was happening?)
2426
-->
2527

26-
2728
## New Behavior
29+
2830
<!--
2931
What is the new behavior?
3032
-->
3133

32-
3334
## Testing Instructions
35+
3436
<!--
3537
Please provide some instructions and other information for how to verify that the feature works.
3638
Examples:
@@ -39,12 +41,12 @@ Examples:
3941
* "This feature also affects 'feature X', so that needs to be tested for regressions as well."
4042
-->
4143

42-
4344
## Other Information
44-
<!-- The more information you can provide, the easier the pull request will be to merge -->
4545

46+
<!-- The more information you can provide, the easier the pull request will be to merge -->
4647

4748
## Status
49+
4850
<!--
4951
Before you open the PR, make sure the items below are done.
5052
If they're not, please open the PR as a Draft.

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Before contributing to this specific repository, please read the [Contribution Guidelines](https://sofie-automation.github.io/sofie-core//docs/for-developers/contribution-guidelines) for the _Sofie_ project.
44

5-
65
## Branches
6+
77
This repository uses the following branches:
88

9-
* **_main_** is our main branch. We consider it stable and it is used in production.
9+
- **_main_** is our main branch. We consider it stable and it is used in production.
1010

1111
We encourage you to base your contributions on the latest **_main_** branch of this repository. The [_Sofie Releases_](https://sofie-automation.github.io/sofie-core//releases) page collects the status and timeline of the _Sofie_ releases.

‎src/__tests__/atem.spec.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Atem', () => {
2424
const conn = new Atem({ disableMultithreaded: true })
2525

2626
try {
27-
const socket = (conn as any).socket as AtemSocket
27+
const socket = (conn as any).client.socket as AtemSocket
2828
expect(socket).toBeTruthy()
2929

3030
expect(AtemSocket).toHaveBeenCalledTimes(1)
@@ -45,7 +45,7 @@ describe('Atem', () => {
4545
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23, maxPacketSize: 500 })
4646

4747
try {
48-
const socket = (conn as any).socket as AtemSocket
48+
const socket = (conn as any).client.socket as AtemSocket
4949
expect(socket).toBeTruthy()
5050

5151
expect(AtemSocket).toHaveBeenCalledTimes(1)
@@ -67,7 +67,7 @@ describe('Atem', () => {
6767
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
6868

6969
try {
70-
const socket = (conn as any).socket as AtemSocket
70+
const socket = (conn as any).client.socket as AtemSocket
7171
expect(socket).toBeTruthy()
7272

7373
socket.connect = jest.fn(() => Promise.resolve(5) as any)
@@ -86,7 +86,7 @@ describe('Atem', () => {
8686
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
8787

8888
try {
89-
const socket = (conn as any).socket as AtemSocket
89+
const socket = (conn as any).client.socket as AtemSocket
9090
expect(socket).toBeTruthy()
9191

9292
socket.disconnect = jest.fn(() => Promise.resolve(35) as any)
@@ -106,7 +106,7 @@ describe('Atem', () => {
106106
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
107107

108108
try {
109-
const socket = (conn as any).socket as AtemSocket
109+
const socket = (conn as any).client.socket as AtemSocket
110110
expect(socket).toBeTruthy()
111111

112112
let nextId = 123
@@ -118,7 +118,7 @@ describe('Atem', () => {
118118

119119
socket.sendCommands = jest.fn(() => Promise.resolve([124]) as any)
120120

121-
const sentQueue = (conn as any)._sentQueue as Record<string, unknown>
121+
const sentQueue = (conn as any).client._sentQueue as Record<string, unknown>
122122
expect(Object.keys(sentQueue)).toHaveLength(0)
123123

124124
const cmd = new CutCommand(0)
@@ -146,7 +146,7 @@ describe('Atem', () => {
146146
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
147147

148148
try {
149-
const socket = (conn as any).socket as AtemSocket
149+
const socket = (conn as any).client.socket as AtemSocket
150150
expect(socket).toBeTruthy()
151151

152152
let nextId = 123
@@ -158,7 +158,7 @@ describe('Atem', () => {
158158

159159
socket.sendCommands = jest.fn(() => Promise.reject(35) as any)
160160

161-
const sentQueue = (conn as any)._sentQueue as Record<string, unknown>
161+
const sentQueue = (conn as any).client._sentQueue as Record<string, unknown>
162162
expect(Object.keys(sentQueue)).toHaveLength(0)
163163

164164
const cmd = new CutCommand(0)
@@ -186,7 +186,7 @@ describe('Atem', () => {
186186
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
187187

188188
try {
189-
const socket = (conn as any).socket as AtemSocket
189+
const socket = (conn as any).client.socket as AtemSocket
190190
socket.sendCommands = jest.fn(() => Promise.resolve([]) as any)
191191

192192
// All commands use the default runOrderGroup (0), so they are sent as one batch
@@ -205,7 +205,7 @@ describe('Atem', () => {
205205
const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23 })
206206

207207
try {
208-
const socket = (conn as any).socket as AtemSocket
208+
const socket = (conn as any).client.socket as AtemSocket
209209
socket.sendCommands = jest.fn(() => Promise.resolve([]) as any)
210210

211211
const mk = (group: number): CutCommand => {

‎src/__tests__/connection.spec.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function createConnection(): BasicAtem {
6060
}
6161

6262
function getChild(conn: BasicAtem): ThreadedClass<AtemSocketChildMock> {
63-
return (conn as any).socket._socketProcess
63+
return (conn as any).client.socket._socketProcess
6464
}
6565

6666
function expectIsValidEnumValue<T>(enumObj: Record<string, T>, value: T): void {
@@ -102,8 +102,8 @@ function runTest(name: string, filename: string): void {
102102

103103
describe('Paths', () => {
104104
const conn = createConnection()
105-
const parser: (b: Buffer) => IDeserializedCommand[] = (conn as any).socket._parseCommands.bind(
106-
(conn as any).socket
105+
const parser: (b: Buffer) => IDeserializedCommand[] = (conn as any).client.socket._parseCommands.bind(
106+
(conn as any).client.socket
107107
)
108108

109109
const commands: IDeserializedCommand[] = []

‎src/__tests__/index.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function createConnection(apiVersion: Enums.ProtocolVersion): Atem {
2222

2323
// conn.on('error', () => null)
2424
conn.sendCommand = jest.fn()
25-
;(conn as any)._state = state
25+
;(conn as any).client._state = state
2626

2727
return conn
2828
}

0 commit comments

Comments
 (0)