Skip to content

Instantly share code, notes, and snippets.

View romshark's full-sized avatar
👨‍💻
Today's game: build an expr. parser in Go: https://play.golang.org/p/QyiDCAQPcSm

Roman Sharkov romshark

👨‍💻
Today's game: build an expr. parser in Go: https://play.golang.org/p/QyiDCAQPcSm
  • tutti.ch | Swiss Marketplace Group
  • Switzerland
  • X @romshar
View GitHub Profile
package main
import (
"log"
"net/http"
"github.com/valyala/fasthttp"
"github.com/arl/statsviz"
)
@romshark
romshark / config.yaml
Created September 13, 2022 13:28
GraphGuard Proxy Config Proposal
# /etc/ggproxy/config.yaml
ingress:
# Address and port of the ingress server.
host: localhost:443
# Optional, enables HTTPS.
tls:
# Certificate file path.
cert-file: ingress.cert
@romshark
romshark / concept.md
Last active September 5, 2022 23:55
GQT 2.0 Syntax Variants

Constraint Expressions

The constraint exspressions syntax proposal was accepted.

This syntax model implies the equality operator by default, for example:

"foo" || "bar"

value equals "foo" or value equals "bar"

@romshark
romshark / problems_using_gql_for_templates.md
Last active September 1, 2022 00:39
Problems of using GraphQL QL for Template Definition

GraphQL Query Language as Template Language

This document briefly explains the rationale behind GQT, a GraphQL templating language specifically developed for GraphGuard, and why using native GraphQL for template definitions isn't a good idea in our opinion.

1. Useless Value Constants

Arguments must have a value by spec, even when the value is useless in case of a template.

query {
  foo(limit: 0 @constraint(OR: [{ge: 2, le: 10}]))

Code:

type T struct { p Int }

The following documents represent different options of representing the AST of the above code using a human-readable textual data format.

package blog
import "std" 1.0 { bytelen }
import "session" 1.0 { field as sessionField }
import "time" 1.0 { Time, now }
import "sys" 1.0 { env }
import "json" 1.0 { JSONValue }
import "github.com/sml/x/jwt" 1.0 {
parsed as jwtParsed
// Types
type MessageBody String
type UserName String
type PasswordHash String
type ConversationTitle String
type ID [32]Byte
type alias UserID ID
type alias ConversationID ID
// Events
event UserCreated {
id *User
name String
passwordHash String
}
event UserDeactivated {
user *User
@romshark
romshark / bench_test.go
Last active April 27, 2020 23:04
Int table transformer
package main
import (
"io"
"testing"
)
type MockReader struct {
Contents []byte
CurrentOffset int
@romshark
romshark / exampleStreams.sml
Last active March 28, 2020 14:49
An example of the service modelling language (SML) describing a real-time notification service (SSE)
# exampleStreams demonstrates a service pushing real-time notification
# events to subscribers (server-side events)
# Clients may subscribe to the multicast through f:Root.subscription.
# Clients may also cancel their subscription through
# f:Root.subscriptionCancelation.
# disconnections will automatically cancel any subscriptions associated
# with the client.
# Stream topics will automatically be created by std::event on
# transaction commit and also automatically deleted when the last
# subscriber is gone