Add support for query key extraction
[com/gs-lite.git] / include / gshub.h
1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3    Licensed under the Apache License, Version 2.0 (the "License");
4    you may not use this file except in compliance with the License.
5    You may obtain a copy of the License at
6
7      http://www.apache.org/licenses/LICENSE-2.0
8
9    Unless required by applicable law or agreed to in writing, software
10    distributed under the License is distributed on an "AS IS" BASIS,
11    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12    See the License for the specific language governing permissions and
13    limitations under the License.
14  ------------------------------------------- */
15
16  /*
17  * gshub.h: interface to GSHUB to announce and discover gs instances, sources and sinks
18  */
19
20 #ifndef GSHUB_H
21 #define GSHUB_H
22
23 #include "gstypes.h"
24 #include "fta.h"
25 #include "fta_stat.h"
26
27 #define DISCOVER_INSTANCE_URL "/v1/discover-instance"
28 #define DISCOVER_INITINSTANCE_URL "/v1/discover-initialized-instance"
29 #define DISCOVER_SOURCE_URL "/v1/discover-source"
30 #define DISCOVER_SINK_URL "/v1/discover-sink"
31 #define DISCOVER_STARTPROCESSING_URL "/v1/discover-start-processing"
32 #define ANNOUNCE_INSTANCE_URL "/v1/announce-instance"
33 #define ANNOUNCE_INITINSTANCE_URL "/v1/announce-initialized-instance"
34 #define ANNOUNCE_SOURCE_URL "/v1/announce-source"
35 #define ANNOUNCE_SINK_URL "/v1/announce-sink"
36 #define ANNOUNCE_STARTPROCESSING_URL "/v1/announce-start-processing"
37 #define ANNOUNCE_STREAM_SUBSCRIPTION "/v1/announce-stream-subscription"
38 #define ANNOUNCE_FTA_INSTANCE "/v1/announce-fta-instance"
39 #define ANNOUNCE_METRICS "/v1/log-metrics"
40
41 typedef struct {
42         gs_uint32_t ip;
43         gs_uint16_t port;
44 } endpoint;
45
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /* saving and retrival of gshub endpoint */
52 gs_retval_t set_hub(endpoint gshub);
53 gs_retval_t get_hub(endpoint* gshub);
54
55 /* savinf and retrieving instance name */
56 gs_retval_t set_instance_name(gs_sp_t instancename);
57 gs_sp_t get_instance_name();
58
59 /* Discover gs instance endpoint by name.
60  * Return value of 0 indicates success. If blocking mode is used return value > 0 indicates that retry is needed. Return value < 0 indicates an error. */
61 gs_retval_t get_instance(endpoint gshub, gs_sp_t instance_name, endpoint* instance, gs_bool_t block);
62
63 /* Discover initialized gs instance endpoint by name.
64  * Return value of 0 indicates success. If blocking mode is used return value > 0 indicates that retry is needed. Return value < 0 indicates an error. */
65 gs_retval_t get_initinstance(endpoint gshub, gs_sp_t instance_name, endpoint* instance, gs_bool_t block);
66
67 /* Discover stream source endpoint by name.
68  * Return value of 0 indicates success. If blocking mode is used return value > 0 indicates that retry is needed. Return value < 0 indicates an error. */
69 gs_retval_t get_streamsource(endpoint gshub, gs_sp_t source_name, endpoint* source, gs_bool_t block);
70
71 /* Discover stream sink endpoint by name.
72  * Return value of 0 indicates success. If blocking mode is used return value > 0 indicates that retry is needed. Return value < 0 indicates an error. */
73 gs_retval_t get_streamsink(endpoint gshub, gs_sp_t sink_name, endpoint* sink, gs_bool_t block);
74
75 /* Discover if an isntance should start processing
76  * Return value of 0 indicates success. If blocking mode is used return value > 0 indicates that retry is needed. Return value < 0 indicates an error. */
77 gs_retval_t get_startprocessing(endpoint gshub, gs_sp_t instance_name, gs_bool_t block);
78
79 /* Announce gs instance endpoint to gshub. Return value of 0 indicates success. */
80 gs_retval_t set_instance(endpoint gshub, gs_sp_t instance_name, endpoint instance);
81
82 /* Announce initialized gs instance endpoint to gshub. Return value of 0 indicates success. */
83 gs_retval_t set_initinstance(endpoint gshub, gs_sp_t instance_name);
84
85 /* Announce stream source endpoint to gshub. Return value of 0 indicates success. */
86 gs_retval_t set_streamsource(endpoint gshub, gs_sp_t source_name, endpoint source);
87
88 /* Announce stream source endpoint to gshub. Return value of 0 indicates success. */
89 gs_retval_t set_streamsink(endpoint gshub, gs_sp_t sink_name, endpoint sink);
90
91 /* Announce to gshub that an instance can start processin. Return value of 0 indicates success. */
92 gs_retval_t set_startprocessing(endpoint gshub, gs_sp_t instance_name);
93
94 /* Announce stream subscription to gshub. Return value of 0 indicates success. */
95 gs_retval_t set_streamsubscription(endpoint gshub, gs_sp_t instance_name, gs_sp_t sink_name);
96
97 /* Announce new fta instantiation to gshub. Return value of 0 indicates success. */
98 gs_retval_t set_ftainstance(endpoint gshub, gs_sp_t instance_name, gs_sp_t ftainstance_name, FTAID* id);
99
100 /* Announce fta instance stats to gshub. Return value of 0 indicates success. */
101 gs_retval_t set_instancestats(endpoint gshub, gs_sp_t instance_name, fta_stat* stats);
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif          /* GSHUB_H */