-
Notifications
You must be signed in to change notification settings - Fork 6
/
Connection.ts
60 lines (58 loc) · 1.57 KB
/
Connection.ts
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
/*
* Copyright (C) 2023 Thirty Meter Telescope International Observatory
* SPDX-License-Identifier: Apache-2.0
*/
import type { ComponentType, Prefix } from '../../../models'
/**
* @internal
*/
const mkConnection =
<T extends ConnectionType>(connectionType: T) =>
(prefix: Prefix, componentType: ComponentType) => ({ connectionType, prefix, componentType })
/**
* @category Location Service
*/
export type ConnectionType = 'akka' | 'tcp' | 'http'
/**
* @category Location Service
*/
export type AkkaConnection = {
connectionType: 'akka'
prefix: Prefix
componentType: ComponentType
}
/**
* @category Location Service
*/
export type HttpConnection = {
connectionType: 'http'
prefix: Prefix
componentType: ComponentType
}
/**
* @category Location Service
*/
export type TcpConnection = {
connectionType: 'tcp'
prefix: Prefix
componentType: ComponentType
}
/**
* @category Location Service
*/
export type Connection = AkkaConnection | HttpConnection | TcpConnection
/**
* A helper function to create Akka Connection
* @category Location Service
*/
export const AkkaConnection: (prefix: Prefix, componentType: ComponentType) => AkkaConnection = mkConnection('akka')
/**
* A helper function to create Http Connection
* @category Location Service
*/
export const HttpConnection: (prefix: Prefix, componentType: ComponentType) => HttpConnection = mkConnection('http')
/**
* A helper function to create TCP Connection
* @category Location Service
*/
export const TcpConnection: (prefix: Prefix, componentType: ComponentType) => TcpConnection = mkConnection('tcp')