ing
This commit is contained in:
parent
e46aa26170
commit
87f68ca3f3
|
@ -6,9 +6,10 @@ import { Anim } from './animation';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { Observable, of, Subscription } from 'rxjs';
|
import { Observable, of, Subscription } from 'rxjs';
|
||||||
import { DiscoveryService } from '../service/discovery.service';
|
import { DiscoveryService } from '../service/discovery.service';
|
||||||
import { DiscoveryNotify } from '../core/discovery-subject';
|
import { DiscoveryNotify } from '../subscriber/discovery.subscriber.subject';
|
||||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||||
import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
|
import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
|
||||||
|
import { DiscoverySubscriber } from '../subscriber/discovery.subscriber';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-discovery',
|
selector: 'of-discovery',
|
||||||
|
@ -28,6 +29,7 @@ export class DiscoveryComponent {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private discoveryService: DiscoveryService,
|
private discoveryService: DiscoveryService,
|
||||||
|
private discoverySubscriber: DiscoverySubscriber,
|
||||||
private store: Store<any>
|
private store: Store<any>
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -37,7 +39,12 @@ export class DiscoveryComponent {
|
||||||
|
|
||||||
this.requested = true;
|
this.requested = true;
|
||||||
|
|
||||||
this.discoverySubscription = this.discoveryService.discoverZone(this.selectedProbe.probe.probeKey, dz).pipe(
|
const discovery$ = this.discoverySubscriber.subscribe();
|
||||||
|
|
||||||
|
discovery$.pipe(
|
||||||
|
tap(() => {
|
||||||
|
this.discoveryService.discoverZone(this.selectedProbe.probe.probeKey, dz);
|
||||||
|
}),
|
||||||
map((discoveryNotify: DiscoveryNotify) => {
|
map((discoveryNotify: DiscoveryNotify) => {
|
||||||
switch (discoveryNotify.method) {
|
switch (discoveryNotify.method) {
|
||||||
case 'DiscoveryService.discoveryStart': {
|
case 'DiscoveryService.discoveryStart': {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
import { RPCService, RPCSubscribeService } from '@loafer/ng-rpc';
|
import { RPCService } from '@loafer/ng-rpc';
|
||||||
import {
|
import {
|
||||||
DiscoverZone as MDDiscoverZone,
|
DiscoverZone as MDDiscoverZone,
|
||||||
DiscoverHost as MDDiscoverHost,
|
DiscoverHost as MDDiscoverHost,
|
||||||
|
@ -13,50 +13,25 @@ import {
|
||||||
Service,
|
Service,
|
||||||
} from '@overflow/commons-typescript/model/discovery';
|
} from '@overflow/commons-typescript/model/discovery';
|
||||||
|
|
||||||
import { DiscoverySubject, DiscoveryNotify } from '../core/discovery-subject';
|
|
||||||
import * as DiscoverStore from '../store/discover';
|
|
||||||
import { DiscoverySubscriber } from '../subscriber/discovery.subscriber';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DiscoveryService {
|
export class DiscoveryService {
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private discoverySubscriber: DiscoverySubscriber,
|
|
||||||
private rpcService: RPCService,
|
private rpcService: RPCService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): Observable<DiscoveryNotify> {
|
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
|
||||||
const discoverySubject: DiscoverySubject = new DiscoverySubject();
|
|
||||||
this.discoverySubscriber.setDiscoverySubject(discoverySubject);
|
|
||||||
|
|
||||||
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
||||||
|
|
||||||
return discoverySubject;
|
|
||||||
}
|
}
|
||||||
public discoverHost(probeID: string, zone: Zone, discoverHost: MDDiscoverHost): Observable<DiscoveryNotify> {
|
public discoverHost(probeID: string, zone: Zone, discoverHost: MDDiscoverHost): void {
|
||||||
const discoverySubject: DiscoverySubject = new DiscoverySubject();
|
|
||||||
this.discoverySubscriber.setDiscoverySubject(discoverySubject);
|
|
||||||
|
|
||||||
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoverHost);
|
this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoverHost);
|
||||||
|
|
||||||
return discoverySubject;
|
|
||||||
}
|
}
|
||||||
public discoverPort(probeID: string, host: Host, discoverPort: MDDiscoverPort): Observable<DiscoveryNotify> {
|
public discoverPort(probeID: string, host: Host, discoverPort: MDDiscoverPort): void {
|
||||||
const discoverySubject: DiscoverySubject = new DiscoverySubject();
|
|
||||||
this.discoverySubscriber.setDiscoverySubject(discoverySubject);
|
|
||||||
|
|
||||||
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoverPort);
|
this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoverPort);
|
||||||
|
|
||||||
return discoverySubject;
|
|
||||||
}
|
}
|
||||||
public discoverService(probeID: string, port: Port, discoverService: MDDiscoverService): Observable<DiscoveryNotify> {
|
public discoverService(probeID: string, port: Port, discoverService: MDDiscoverService): void {
|
||||||
const discoverySubject: DiscoverySubject = new DiscoverySubject();
|
|
||||||
this.discoverySubscriber.setDiscoverySubject(discoverySubject);
|
|
||||||
|
|
||||||
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoverService);
|
this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoverService);
|
||||||
|
|
||||||
return discoverySubject;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,6 @@ export interface DiscoveryNotify {
|
||||||
params: Date | Zone | Host | Port | Service;
|
params: Date | Zone | Host | Port | Service;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DiscoverySubject extends Subject<DiscoveryNotify> {
|
export class DiscoverySubscriberSubject extends Subject<DiscoveryNotify> {
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { RPCSubscriber } from '@loafer/ng-rpc';
|
import { RPCSubscriber } from '@loafer/ng-rpc';
|
||||||
|
@ -13,28 +14,27 @@ import {
|
||||||
Port,
|
Port,
|
||||||
Service,
|
Service,
|
||||||
} from '@overflow/commons-typescript/model/discovery';
|
} from '@overflow/commons-typescript/model/discovery';
|
||||||
import { DiscoverySubject } from '../core/discovery-subject';
|
import { DiscoverySubscriberSubject, DiscoveryNotify } from './discovery.subscriber.subject';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DiscoverySubscriber {
|
export class DiscoverySubscriber {
|
||||||
discoverySubject: DiscoverySubject | null;
|
discoverySubscriberSubject: DiscoverySubscriberSubject;
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private loggerService: LoggerService,
|
private loggerService: LoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.discoverySubscriberSubject = new DiscoverySubscriberSubject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name
|
* name
|
||||||
*/
|
*/
|
||||||
public setDiscoverySubject(discoverySubject: DiscoverySubject) {
|
public subscribe(): Observable<DiscoveryNotify> {
|
||||||
this.discoverySubject = discoverySubject;
|
return this.discoverySubscriberSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private publish(method: string, params: any): void {
|
private publish(method: string, params: any): void {
|
||||||
if (null !== this.discoverySubject) {
|
this.discoverySubscriberSubject.next({ method: method, params: params });
|
||||||
this.discoverySubject.next({method: method, params: params});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RPCSubscriber({ method: 'DiscoveryService.discoveryStart' })
|
@RPCSubscriber({ method: 'DiscoveryService.discoveryStart' })
|
||||||
|
@ -49,7 +49,6 @@ export class DiscoverySubscriber {
|
||||||
this.loggerService.debug('DiscoverySubscriber.discoveryStop stopDate:', stopDate);
|
this.loggerService.debug('DiscoverySubscriber.discoveryStop stopDate:', stopDate);
|
||||||
|
|
||||||
this.publish('DiscoveryService.discoveryStop', stopDate);
|
this.publish('DiscoveryService.discoveryStop', stopDate);
|
||||||
this.setDiscoverySubject(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user