|
9 | 9 | package dev.restate.sdk.kotlin.endpoint
|
10 | 10 |
|
11 | 11 | import dev.restate.sdk.endpoint.Endpoint
|
| 12 | +import dev.restate.sdk.endpoint.definition.HandlerDefinition |
| 13 | +import dev.restate.sdk.endpoint.definition.ServiceDefinition |
| 14 | +import kotlin.time.Duration |
| 15 | +import kotlin.time.toJavaDuration |
| 16 | +import kotlin.time.toKotlinDuration |
12 | 17 |
|
13 | 18 | /** Endpoint builder function. */
|
14 | 19 | fun endpoint(init: Endpoint.Builder.() -> Unit): Endpoint {
|
15 | 20 | val builder = Endpoint.builder()
|
16 | 21 | builder.init()
|
17 | 22 | return builder.build()
|
18 | 23 | }
|
| 24 | + |
| 25 | +/** |
| 26 | + * Documentation as shown in the UI, Admin REST API, and the generated OpenAPI documentation of this |
| 27 | + * service. |
| 28 | + */ |
| 29 | +var ServiceDefinition.Configurator.documentation: String? |
| 30 | + get() { |
| 31 | + return this.documentation() |
| 32 | + } |
| 33 | + set(value) { |
| 34 | + this.documentation(value) |
| 35 | + } |
| 36 | + |
| 37 | +/** Service metadata, as propagated in the Admin REST API. */ |
| 38 | +var ServiceDefinition.Configurator.metadata: Map<String, String>? |
| 39 | + get() { |
| 40 | + return this.metadata() |
| 41 | + } |
| 42 | + set(value) { |
| 43 | + this.metadata(value) |
| 44 | + } |
| 45 | + |
| 46 | +/** |
| 47 | + * This timer guards against stalled invocations. Once it expires, Restate triggers a graceful |
| 48 | + * termination by asking the invocation to suspend (which preserves intermediate progress). |
| 49 | + * |
| 50 | + * The [abortTimeout] is used to abort the invocation, in case it doesn't react to the request to |
| 51 | + * suspend. |
| 52 | + * |
| 53 | + * This overrides the default inactivity timeout configured in the restate-server for all |
| 54 | + * invocations to this service. |
| 55 | + * |
| 56 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 57 | + * otherwise the service discovery will fail. |
| 58 | + */ |
| 59 | +var ServiceDefinition.Configurator.inactivityTimeout: Duration? |
| 60 | + get() { |
| 61 | + return this.inactivityTimeout()?.toKotlinDuration() |
| 62 | + } |
| 63 | + set(value) { |
| 64 | + this.inactivityTimeout(value?.toJavaDuration()) |
| 65 | + } |
| 66 | + |
| 67 | +/** |
| 68 | + * This timer guards against stalled service/handler invocations that are supposed to terminate. The |
| 69 | + * abort timeout is started after the [inactivityTimeout] has expired and the service/handler |
| 70 | + * invocation has been asked to gracefully terminate. Once the timer expires, it will abort the |
| 71 | + * service/handler invocation. |
| 72 | + * |
| 73 | + * This timer potentially *interrupts* user code. If the user code needs longer to gracefully |
| 74 | + * terminate, then this value needs to be set accordingly. |
| 75 | + * |
| 76 | + * This overrides the default abort timeout configured in the restate-server for all invocations to |
| 77 | + * this service. |
| 78 | + * |
| 79 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 80 | + * otherwise the service discovery will fail. |
| 81 | + */ |
| 82 | +var ServiceDefinition.Configurator.abortTimeout: Duration? |
| 83 | + get() { |
| 84 | + return this.abortTimeout()?.toKotlinDuration() |
| 85 | + } |
| 86 | + set(value) { |
| 87 | + this.abortTimeout(value?.toJavaDuration()) |
| 88 | + } |
| 89 | + |
| 90 | +/** |
| 91 | + * The retention duration of idempotent requests to this service. |
| 92 | + * |
| 93 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 94 | + * otherwise the service discovery will fail. |
| 95 | + */ |
| 96 | +var ServiceDefinition.Configurator.idempotencyRetention: Duration? |
| 97 | + get() { |
| 98 | + return this.idempotencyRetention()?.toKotlinDuration() |
| 99 | + } |
| 100 | + set(value) { |
| 101 | + this.idempotencyRetention(value?.toJavaDuration()) |
| 102 | + } |
| 103 | + |
| 104 | +/** |
| 105 | + * The journal retention. When set, this applies to all requests to all handlers of this service. |
| 106 | + * |
| 107 | + * In case the request has an idempotency key, the [idempotencyRetention] caps the journal retention |
| 108 | + * time. |
| 109 | + * |
| 110 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 111 | + * otherwise the service discovery will fail. |
| 112 | + * |
| 113 | + * @return this |
| 114 | + */ |
| 115 | +var ServiceDefinition.Configurator.journalRetention: Duration? |
| 116 | + get() { |
| 117 | + return this.journalRetention()?.toKotlinDuration() |
| 118 | + } |
| 119 | + set(value) { |
| 120 | + this.journalRetention(value?.toJavaDuration()) |
| 121 | + } |
| 122 | + |
| 123 | +/** |
| 124 | + * When set to `true`, lazy state will be enabled for all invocations to this service. This is |
| 125 | + * relevant only for workflows and virtual objects. |
| 126 | + * |
| 127 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 128 | + * otherwise the service discovery will fail. |
| 129 | + */ |
| 130 | +var ServiceDefinition.Configurator.enableLazyState: Boolean? |
| 131 | + get() { |
| 132 | + return this.enableLazyState() |
| 133 | + } |
| 134 | + set(value) { |
| 135 | + this.enableLazyState(value) |
| 136 | + } |
| 137 | + |
| 138 | +/** |
| 139 | + * When set to `true` this service, with all its handlers, cannot be invoked from the restate-server |
| 140 | + * HTTP and Kafka ingress, but only from other services. |
| 141 | + * |
| 142 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 143 | + * otherwise the service discovery will fail. |
| 144 | + */ |
| 145 | +var ServiceDefinition.Configurator.ingressPrivate: Boolean? |
| 146 | + get() { |
| 147 | + return this.ingressPrivate() |
| 148 | + } |
| 149 | + set(value) { |
| 150 | + this.ingressPrivate(value) |
| 151 | + } |
| 152 | + |
| 153 | +/** |
| 154 | + * Set the acceptable content type when ingesting HTTP requests. Wildcards can be used, e.g. |
| 155 | + * `application/*` or `*/*`. |
| 156 | + */ |
| 157 | +var HandlerDefinition.Configurator.acceptContentType: String? |
| 158 | + get() { |
| 159 | + return this.acceptContentType() |
| 160 | + } |
| 161 | + set(value) { |
| 162 | + this.acceptContentType(value) |
| 163 | + } |
| 164 | + |
| 165 | +/** |
| 166 | + * Documentation as shown in the UI, Admin REST API, and the generated OpenAPI documentation of this |
| 167 | + * handler. |
| 168 | + */ |
| 169 | +var HandlerDefinition.Configurator.documentation: String? |
| 170 | + get() { |
| 171 | + return this.documentation() |
| 172 | + } |
| 173 | + set(value) { |
| 174 | + this.documentation(value) |
| 175 | + } |
| 176 | + |
| 177 | +/** Handler metadata, as propagated in the Admin REST API. */ |
| 178 | +var HandlerDefinition.Configurator.metadata: Map<String, String>? |
| 179 | + get() { |
| 180 | + return this.metadata() |
| 181 | + } |
| 182 | + set(value) { |
| 183 | + this.metadata(value) |
| 184 | + } |
| 185 | + |
| 186 | +/** |
| 187 | + * This timer guards against stalled invocations. Once it expires, Restate triggers a graceful |
| 188 | + * termination by asking the invocation to suspend (which preserves intermediate progress). |
| 189 | + * |
| 190 | + * The [abortTimeout] is used to abort the invocation, in case it doesn't react to the request to |
| 191 | + * suspend. |
| 192 | + * |
| 193 | + * This overrides the inactivity timeout set for the service and the default set in restate-server. |
| 194 | + * |
| 195 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 196 | + * otherwise the service discovery will fail. |
| 197 | + */ |
| 198 | +var HandlerDefinition.Configurator.inactivityTimeout: Duration? |
| 199 | + get() { |
| 200 | + return this.inactivityTimeout()?.toKotlinDuration() |
| 201 | + } |
| 202 | + set(value) { |
| 203 | + this.inactivityTimeout(value?.toJavaDuration()) |
| 204 | + } |
| 205 | + |
| 206 | +/** |
| 207 | + * This timer guards against stalled invocations that are supposed to terminate. The abort timeout |
| 208 | + * is started after the [inactivityTimeout] has expired and the invocation has been asked to |
| 209 | + * gracefully terminate. Once the timer expires, it will abort the invocation. |
| 210 | + * |
| 211 | + * This timer potentially *interrupts* user code. If the user code needs longer to gracefully |
| 212 | + * terminate, then this value needs to be set accordingly. |
| 213 | + * |
| 214 | + * This overrides the abort timeout set for the service and the default set in restate-server. |
| 215 | + * |
| 216 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 217 | + * otherwise the service discovery will fail. |
| 218 | + */ |
| 219 | +var HandlerDefinition.Configurator.abortTimeout: Duration? |
| 220 | + get() { |
| 221 | + return this.abortTimeout()?.toKotlinDuration() |
| 222 | + } |
| 223 | + set(value) { |
| 224 | + this.abortTimeout(value?.toJavaDuration()) |
| 225 | + } |
| 226 | + |
| 227 | +/** |
| 228 | + * The retention duration of idempotent requests to this service. |
| 229 | + * |
| 230 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 231 | + * otherwise the service discovery will fail. |
| 232 | + */ |
| 233 | +var HandlerDefinition.Configurator.idempotencyRetention: Duration? |
| 234 | + get() { |
| 235 | + return this.idempotencyRetention()?.toKotlinDuration() |
| 236 | + } |
| 237 | + set(value) { |
| 238 | + this.idempotencyRetention(value?.toJavaDuration()) |
| 239 | + } |
| 240 | + |
| 241 | +/** |
| 242 | + * The retention duration for this workflow handler. |
| 243 | + * |
| 244 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 245 | + * otherwise the service discovery will fail. |
| 246 | + */ |
| 247 | +var HandlerDefinition.Configurator.workflowRetention: Duration? |
| 248 | + get() { |
| 249 | + return this.workflowRetention()?.toKotlinDuration() |
| 250 | + } |
| 251 | + set(value) { |
| 252 | + this.workflowRetention(value?.toJavaDuration()) |
| 253 | + } |
| 254 | + |
| 255 | +/** |
| 256 | + * The journal retention for invocations to this handler. |
| 257 | + * |
| 258 | + * In case the request has an idempotency key, the [idempotencyRetention] caps the journal retention |
| 259 | + * time. |
| 260 | + * |
| 261 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 262 | + * otherwise the service discovery will fail. |
| 263 | + */ |
| 264 | +var HandlerDefinition.Configurator.journalRetention: Duration? |
| 265 | + get() { |
| 266 | + return this.journalRetention()?.toKotlinDuration() |
| 267 | + } |
| 268 | + set(value) { |
| 269 | + this.journalRetention(value?.toJavaDuration()) |
| 270 | + } |
| 271 | + |
| 272 | +/** |
| 273 | + * When set to `true` this handler cannot be invoked from the restate-server HTTP and Kafka ingress, |
| 274 | + * but only from other services. |
| 275 | + * |
| 276 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 277 | + * otherwise the service discovery will fail. |
| 278 | + */ |
| 279 | +var HandlerDefinition.Configurator.ingressPrivate: Boolean? |
| 280 | + get() { |
| 281 | + return this.ingressPrivate() |
| 282 | + } |
| 283 | + set(value) { |
| 284 | + this.ingressPrivate(value) |
| 285 | + } |
| 286 | + |
| 287 | +/** |
| 288 | + * When set to `true`, lazy state will be enabled for all invocations to this handler. This is |
| 289 | + * relevant only for workflows and virtual objects. |
| 290 | + * |
| 291 | + * *NOTE:* You can set this field only if you register this service against restate-server >= 1.4, |
| 292 | + * otherwise the service discovery will fail. |
| 293 | + */ |
| 294 | +var HandlerDefinition.Configurator.enableLazyState: Boolean? |
| 295 | + get() { |
| 296 | + return this.enableLazyState() |
| 297 | + } |
| 298 | + set(value) { |
| 299 | + this.enableLazyState(value) |
| 300 | + } |
0 commit comments