This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TOOLS := $(shell cat tools.go | grep _ | awk -F'"' '{print $$2}') | |
| .SECONDARY: bin/.tools | |
| bin/.tools: bin/ tools.go | |
| go install $(TOOLS) | |
| @touch $@ | |
| .PHONY: tools | |
| tools: bin/.tools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const maxStackLength = 10 | |
| const skipCallers = 5 | |
| func stacktrace() string { | |
| stackBuf := make([]uintptr, maxStackLength) | |
| length := runtime.Callers(skipCallers, stackBuf[:]) | |
| stack := stackBuf[:length] | |
| trace := "" | |
| frames := runtime.CallersFrames(stack) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PKG_PATH := pkg | |
| PROTOC := protoc | |
| PROTOS := $(sort $(shell find ./$(PKG_PATH) -type f -name '*.proto' -print)) | |
| GO_PROTO_SOURCES := $(PROTOS:%.proto=%.pb.go) | |
| GW_PROTO_SOURCES := $(PROTOS:%.proto=%.pb.gw.go) | |
| SWAGGER_SOURCES := $(PROTOS:%.proto=%.swagger.json) | |
| PROTO_IMPORT_PATH := \ | |
| -I $(PKG_PATH) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *, | |
| *::before, | |
| *::after{box-sizing:border-box;} | |
| a{text-decoration:none; color:inherit; cursor:pointer;} | |
| button{background-color:transparent; color:inherit; border-width:0; padding:0; cursor:pointer;} | |
| figure{margin:0;} | |
| input::-moz-focus-inner {border:0; padding:0; margin:0;} | |
| ul, li, ol, dd{margin:0; padding:0; list-style:none;} | |
| h1, h2, h3, h4, h5, h6{margin:0; font-size:inherit; font-weight:inherit;} | |
| p{margin:0;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Combine | |
| protocol ActionType {} | |
| protocol StateType {} | |
| struct Command<Action: ActionType> { | |
| let execute: (SendFunction<Action>) -> Void | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export declare type Optional<T> = T | undefined; | |
| export function getOptional<T>(optional: Optional<T>, defaultVal?: T): T { | |
| if (optional) { | |
| return <T>optional; | |
| } | |
| if (defaultVal != undefined) { | |
| return defaultVal; | |
| } | |
| throw new Error("the value of optional is undefined"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { grpc } from "grpc-web-client"; | |
| // Use evn var if specified (used in development) or relative path to api otherwise. | |
| export const API_URL = process.env.REACT_APP_API_URL ? process.env.REACT_APP_API_URL : "/api"; | |
| const GRPC_WEB_REQUEST = "GRPC_WEB_REQUEST"; | |
| // Descriptor of a grpc-web payload | |
| // life-cycle methods mirror grpc-web but allow for an action to be dispatched when triggered | |
| export type GrpcActionPayload<ReqT extends grpc.ProtobufMessage, RespT extends grpc.ProtobufMessage> = { | |
| // The method descriptor to use for a gRPC request, equivalent to grpc.invoke(methodDescriptor, ...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export interface Action<T extends string> { | |
| type: T; | |
| } | |
| export interface ActionWithPayload<T extends string, P> extends Action<T> { | |
| payload: P; | |
| } | |
| export function createAction<T extends string>(type: T): Action<T>; | |
| export function createAction<T extends string, P>(type: T, payload: P): ActionWithPayload<T, P>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doFetch<ReqT extends { serializeBinary(): Uint8Array }, RespT> | |
| (method: string, req: ReqT, respClass: { new(): RespT, deserializeBinary(bytes: Uint8Array): RespT }): Promise<RespT> { | |
| const params: RequestInit = { | |
| headers: { | |
| "Accept": PROTO_CONTENT_TYPE, | |
| "Content-Type": PROTO_CONTENT_TYPE, | |
| }, | |
| method: "POST", | |
| body: toArrayBuffer(req.serializeBinary()), | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as protos from "./protos"; | |
| import pb = protos.exemplar; | |
| const HOST = "https://localhost:1234"; | |
| const PROTO_CONTENT_TYPE = "application/x-protobuf"; | |
| interface ResponseMessageBuilder<PropT, RespT> { | |
| new(properties?: PropT): RespT; | |
| encode(message: PropT, writer?: protobuf.Writer): protobuf.Writer; | |
| decode(reader: (protobuf.Reader | Uint8Array), length?: number): RespT; |
NewerOlder