@@ -22,30 +22,57 @@ export default class ActorProxyBuilder<T> {
22
22
actorClient : ActorClient ;
23
23
actorAbstractClass : Class < T > ;
24
24
25
- constructor ( actorTypeName : string , actorTypeClass : Class < T > , daprClient : DaprClient ) ;
25
+ constructor ( actorTypeClass : Class < T > , daprClient : DaprClient ) ;
26
+ constructor (
27
+ actorTypeClass : Class < T > ,
28
+ host : string ,
29
+ port : string ,
30
+ communicationProtocol : CommunicationProtocolEnum ,
31
+ clientOptions : DaprClientOptions ,
32
+ ) ;
26
33
constructor (
27
34
actorTypeName : string ,
28
- abstractClass : Class < T > ,
35
+ actorTypeClass : Class < T > ,
36
+ daprClient : DaprClient
37
+ ) ;
38
+ constructor (
39
+ actorTypeName : string ,
40
+ actorTypeClass : Class < T > ,
29
41
host : string ,
30
42
port : string ,
31
43
communicationProtocol : CommunicationProtocolEnum ,
32
44
clientOptions : DaprClientOptions ,
33
45
) ;
34
- constructor ( actorTypeName : string , abstractClass : Class < T > , ...args : any [ ] ) {
46
+ constructor ( ...args : any [ ] ) {
47
+ let actorTypeName : string ;
48
+ let actorTypeClass : Class < T > ;
49
+ let rest : any [ ] ;
50
+
51
+ // Determine if the first argument is a string (actorTypeName) or a class
52
+ if ( typeof args [ 0 ] === "string" ) {
53
+ actorTypeName = args [ 0 ] ;
54
+ actorTypeClass = args [ 1 ] ;
55
+ rest = args . slice ( 2 ) ;
56
+ } else {
57
+ actorTypeClass = args [ 0 ] ;
58
+ actorTypeName = actorTypeClass . name ;
59
+ rest = args . slice ( 1 ) ;
60
+ }
61
+
35
62
this . actorTypeName = actorTypeName ;
36
- this . actorAbstractClass = abstractClass ;
63
+ this . actorAbstractClass = actorTypeClass ;
37
64
38
65
// Create the actor client based on the provided arguments
39
- if ( args . length == 1 ) {
40
- const [ daprClient ] = args ;
66
+ if ( rest . length == 1 ) {
67
+ const [ daprClient ] = rest ;
41
68
this . actorClient = new ActorClient (
42
69
daprClient . options . daprHost ,
43
70
daprClient . options . daprPort ,
44
71
daprClient . options . communicationProtocol ,
45
72
daprClient . options ,
46
73
) ;
47
74
} else {
48
- const [ host , port , communicationProtocol , clientOptions ] = args ;
75
+ const [ host , port , communicationProtocol , clientOptions ] = rest ;
49
76
this . actorClient = new ActorClient ( host , port , communicationProtocol , clientOptions ) ;
50
77
}
51
78
}
0 commit comments