Skip to content

Commit

Permalink
Azure Storage Queue Reaction (#114)
Browse files Browse the repository at this point in the history
* initial commit

* advanced example

* inline docs

* js examples

* rename

* external images

* wip

* dotnet reaction sdk

* wip

* examples

* wip

* wip

* packaging

* error handling

* wip

* license headers

* wip

* readme

* wip

* wip

* Update default-reaction-providers.yaml

* nit

* enum validation
  • Loading branch information
danielgerlag authored Nov 21, 2024
1 parent 44a2329 commit cd2f793
Show file tree
Hide file tree
Showing 20 changed files with 976 additions and 319 deletions.
17 changes: 12 additions & 5 deletions cli/service/resources/default-reaction-providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,25 @@ kind: ReactionProvider
name: StorageQueue
spec:
services:
storage_queue:
reaction:
image: reaction-storage-queue
config_schema:
type: object
properties:
StorageConnectionString:
connectionString:
type: string
QueueName:
endpoint:
type: string
queueName:
type: string
format:
type: string
enum:
- "packed"
- "unpacked"
default: "packed"
required:
- StorageConnectionString
- QueueName
- queueName
---
apiVersion: v1
kind: ReactionProvider
Expand Down
1 change: 1 addition & 0 deletions control-planes/mgmt_api/src/api/v1/models/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub struct JsonSchemaDto {
pub items: Option<Box<JsonSchemaDto>>, // For array types

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "enum")]
pub enum_values: Option<Vec<serde_json::Value>>,

#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
1 change: 1 addition & 0 deletions control-planes/mgmt_api/src/domain/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ pub struct JsonSchema {
pub items: Option<Box<JsonSchema>>, // For array types

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "enum")]
pub enum_values: Option<Vec<serde_json::Value>>,

#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
40 changes: 7 additions & 33 deletions reactions/azure/storagequeue-reaction/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet@sha256:22414f335b79654fb42257326e7f17f18edf8f912578fc33a55c5dd609bd022e AS base
# mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 80

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk@sha256:6df1177e48b55272316d08f19cb383483af82aca5cdc67a76c414bc200847624 AS build
# mcr.microsoft.com/dotnet/sdk:6.0
FROM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["storagequeue-reaction.csproj", "."]
RUN dotnet restore "./storagequeue-reaction.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "storagequeue-reaction.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "storagequeue-reaction.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM base AS final
FROM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "storagequeue-reaction.dll"]
COPY --from=build /app/build .
ENTRYPOINT ["/app/storagequeue-reaction"]
13 changes: 9 additions & 4 deletions reactions/azure/storagequeue-reaction/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: default docker-build kind-load
.PHONY: default docker-build kind-load generate-types

CLUSTER_NAME ?= kind
IMAGE_PREFIX ?= drasi-project
Expand All @@ -8,13 +8,18 @@ DOCKERX_OPTS ?= --load --cache-to type=inline,mode=max
default: docker-build

docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/reaction-storagequeue:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)
docker buildx build . -t $(IMAGE_PREFIX)/reaction-storage-queue:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/reaction-storagequeue:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_PREFIX)/reaction-storage-queue:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

test:
@echo "No tests to run yet"

lint-check:
@echo "No lint checks to run yet"
@echo "No lint checks to run yet"

generate-types:
npm run clean --prefix ../../../typespec
npm run build ./output-unpacked --prefix ../../../typespec
quicktype --src-lang schema -l cs -o Models/Unpacked.generated.cs ../../../typespec/output-unpacked/_generated/@typespec/json-schema/*.yaml --framework SystemTextJson --namespace Drasi.Reactions.StorageQueue.Models.Unpacked
53 changes: 0 additions & 53 deletions reactions/azure/storagequeue-reaction/Models/ChangeNotification.cs

This file was deleted.

8 changes: 8 additions & 0 deletions reactions/azure/storagequeue-reaction/Models/Unpacked.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Text.Json;

namespace Drasi.Reactions.StorageQueue.Models.Unpacked;

public static class ModelOptions
{
public static JsonSerializerOptions JsonOptions => Converter.Settings;
}
Loading

0 comments on commit cd2f793

Please sign in to comment.