囧 -《哪吒之魔童降世》观后感

July 28, 2019

在想标题的时候,看到主演里有 囧(森瑟夫),突然觉得好贴切感受,在观影时大部分是这个表情。

如何从0到1实现一门语言

July 26, 2019

语言就是程序员的酒精/Languages are alcohol to programmer。🍺 ⏤ wener

Java with GraphQL

May 21, 2018

JraphQL

Java with GraphQL

ModuleDescription
jraphql-langGraphQL language representation
jraphql-runtimeGraphQL execution engine
jraphql-parser-antlrParser written in Antlr4 parse to jraphql-lang

Get Started

<dependency>
<groupId>me.wener.jraphql</groupId>
<artifactId>jraphql-runtimer</artifactId>
<version>0.0.6</version>
</dependency>
<dependency>
<groupId>me.wener.jraphql</groupId>
<artifactId>jraphql-parser-antlr</artifactId>
<version>0.0.6</version>
</dependency>

Features

Language representation

FeatureDescription
Serializablecan parse or stringify to or from JSON
Immutablefriendly to cache or precompile
Buildableevery type has a builder for it generated by lombok.
Pluggablelanguage representation is not related to parser impl

Syntax Extension

Add extend by name syntax for object and interface

Weave multi schemas

# common.graphqls
scalar Version
# crm.graphqls
type CrmQuery {
customer(id:ID!):Customer
crmVersion: Version!
}
type CrmUser {
customers: [Customer]
}
extend type Query by CrmQuery
extend type User by CrmUser
# erp.graphqls
type ErpQuery {
product(id:ID!):Product
}
extend type Query by ErpQuery

Conditional schema

# Only admin can see and use these methods
type AdminMutation {
changePassword(id:ID,password:String): ChangePasswordPayload
}
extend type Mutation by AdminMutation @Role(role:"admin")

Allowed directives on directive definition, add DIRECTIVE location

directive @JavaType(type:String) on DIRECTIVE
directive @Auth(value:String) @JavaType(type:"Auth") on FIELD_DEFINITION;

Allowed schema has optional name

schema Test {
query: MyQuery
}

Runtime Extension

  1. Type implements interface don't need to write the fields again.
interface Node {
id: ID!
}
type User implements Node {
# id: ID! # This is optional
}
  1. Can disable introspection
    • new MetaResolver().setDisableIntrospection(true)

Embeddable Schema

JraphQL Runtime contain a embedded schema MetaSchema, generated by EmbededSchema.

  • Parse Schema
  • Serialize to JSON
  • Best compress GZip
  • Encode use mime base64
  • Original JSON 32631 byte -> Encoded Base64 5352 byte

Example

StarWar

Queries you can try

mutation addRev {
createReview(episode: EMPIRE, review: {stars: 4, commentary: "Ok Good"}) {
stars
commentary
}
}
query rev($e:Episode = EMPIRE) {
hero(episode: $e) {
id
name
appearsIn
}
reviews(episode: $e) {
stars
commentary
}
}
query search {
search(text: "o") {
__typename
... on Human {
id
name
}
... on Droid {
primaryFunction
}
... on Starship {
length
}
}
}
query baseQuery {
starship(id: "3000") {
id
name
length(unit: FOOT)
}
character(id: "2000") {
id
... on Human {
mass
starships {
name
}
}
... on Droid {
name
appearsIn
}
}
human(id: "1003") {
friendsConnection(after: "1002") {
friends {
name
}
pageInfo {
hasNextPage
startCursor
endCursor
}
}
friends {
name
}
}
}

Work with GoaphQL

GoaphQL can generate code from schema that depends on jrapgql-api, can directly run on jraphql-graphql-java-adapter.

The generated code is static type and full featured, everything is an interface.

进击的程序猿

January 19, 2017

进击的程序猿

2016 年会节目

分布式架构手记

August 25, 2016

这几天尝试了很多的 *aaS, 期望能找到在当前架构下适合公司后续发展的一个系统架构, 然而一路下来发现并没那么简单.

Go Redis module

August 9, 2016

Writing Redis Module in Golang.

Guava 简介

October 2, 2015

Overviews - Five Ws

问题答案
是什么一套开源的 Java 公共组件
谁开发的主要由 Google 工程师开发维护
哪里用所有使用 Java 的地方
什么时候出现的2008年九月 第一个Google Collection版本出现在 maven 仓库;
2010年四月第一个Guava版本出现在maven 仓库
什么使用为什么不使用 ?

一致性Hash算法

November 12, 2014

ketama

该算法最开始是开发来替代memcached键到服务器的映射算法的.

消息中间件简介 mom-intro

September 6, 2014
  1. 异步 VS 同步

同步

分布式对象技术(Distributed Object Technologies - DOT), 远程过程调用RPC: 同步操作 (调用被阻塞,直到被调用者返回).