golang
文章平均质量分 62
hello_ejb3
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
聊聊golang的Pseudo-versions
## 序本文主要研究一下golang的Pseudo-versionsPseudo-versions定义Pseudo-versions,中文大概是伪版本的意思,就是没有打语义版本tag(semantic version tags)的会使用伪版本格式类似v0.0.0-yyyymmddhhmmss-abcdefabcdef,中间的时间为UTC时间(东八区为utc+8),最后的12位为git commit的hash的前12位formsvX.0.0-yyyymmddhhmmss-abcdefabc原创 2022-05-16 00:17:08 · 326 阅读 · 0 评论 -
技术文档画图工具箱
序本文主要介绍一下撰写技术文档中可能会用的一些画图工具。这里主要分为两大派,一派是直接拖拽完成,一派是通过代码来完成UI工具主要有processon、draw.io、excalidraw、archimatetool、cloudcraft.coprocesson架构图https://www.processon.com/view/6220b5de1e085333a8970d39?fromnew=1类图https://www.processon.com/view/556ff07de4b09b5原创 2022-04-01 12:02:30 · 411 阅读 · 0 评论 -
go微服务开发工具箱
序使用golang开发了一阵子业务代码,本文主要梳理一下自己的使用感受,并总结一下常用的类库,方便查阅。由于本人是java重度使用者,不免加以对比吐槽一下,请见谅。go做业务开发?对比java这里说说用go做业务开发的感受:优点云原生首选,省内存挺适合写脚本的,可替代python缺点没使用好会panic,线上服务直接进程退出还挺严重的go没有maven的SNAPSHOT版本,基于commit hash加日期作为伪版本,很容易出现invalid version,体验非常不好,不原创 2022-02-20 22:27:40 · 418 阅读 · 0 评论 -
聊聊tunny的workerWrapper
序本文主要研究一下tunny的workerWrapperworkerWrappertype workerWrapper struct { worker Worker interruptChan chan struct{} // reqChan is NOT owned by this type, it is used to send requests for work. reqChan chan<- workRequest // closeChan can be cl原创 2021-04-28 22:57:04 · 376 阅读 · 0 评论 -
聊聊golang的tunny
序本文主要研究一下tunnyWorkertype Worker interface { // Process will synchronously perform a job and return the result. Process(interface{}) interface{} // BlockUntilReady is called before each job is processed and must block the // calling goroutine until原创 2021-04-27 23:41:02 · 516 阅读 · 0 评论 -
聊聊xxl-job-executor-go的Task
序本文主要研究一下xxl-job-executor-go的TaskTask//任务type Task struct { Id int64 Name string Ext context.Context Param *RunReq fn TaskFunc Cancel context.CancelFunc StartTime int64 EndTime int64 //日志 log Logger}type T原创 2021-04-26 22:53:28 · 228 阅读 · 0 评论 -
聊聊xxl-job-executor-go
序本文主要研究一下xxl-job-executor-goExecutor//执行器type Executor interface { //初始化 Init(...Option) //日志查询 LogHandler(handler LogHandler) //注册任务 RegTask(pattern string, task TaskFunc) //运行任务 RunTask(writer http.ResponseWriter, request *http.Request) //杀死原创 2021-04-25 23:37:10 · 612 阅读 · 0 评论 -
聊聊dbsync的jobs
序本文主要研究一下dbsync的jobsJob//Job represents db sync jobtype Job struct { ID string Error string Status string Progress Progress Items []*Transferable Chunked bool mutex *sync.Mutex StartTime time.Time EndTime *time.Time原创 2021-04-23 22:25:43 · 200 阅读 · 0 评论 -
聊聊dbsync的Schedulable
序本文主要研究一下dbsync的SchedulableSchedulable//Schedulable represent an abstraction that can be scheduletype Schedulable struct { URL string ID string *contract.Sync Schedule *contract.Schedule Status string status uint32}//NewSchedulableFromURL原创 2021-04-22 23:14:36 · 319 阅读 · 1 评论 -
聊聊dbsync的Criterion
序本文主要研究一下dbsync的CriterionCriterion//Criterion represents criteriontype Criterion fmt.StringerCriterion是一个fmt.Stringer类型betweentype between struct { from int to int}func (b between) String() string { return fmt.Sprintf("BETWEEN %v AND %v",原创 2021-04-21 23:19:42 · 131 阅读 · 0 评论 -
聊聊go.cqrs的EventHandler
序本文主要研究一下go.cqrs的EventHandlerEventHandlertype EventHandler interface { Handle(EventMessage)}EventHandler定义了Handle方法EventMessage// EventMessage is the interface that a command must implement.type EventMessage interface { // AggregateID returns原创 2021-04-10 23:02:35 · 179 阅读 · 0 评论 -
聊聊go.cqrs的Dispatcher
序本文主要研究一下go.cqrs的DispatcherDispatchertype Dispatcher interface { Dispatch(CommandMessage) error RegisterHandler(CommandHandler, ...interface{}) error}Dispatcher接口定义了Dispatch、RegisterHandler方法InMemoryDispatchertype InMemoryDispatcher struct { h原创 2021-04-09 22:37:25 · 160 阅读 · 0 评论 -
聊聊go.cqrs的DomainRepository
序本文主要研究一下go.cqrs的DomainRepositoryDomainRepository// DomainRepository is the interface that all domain repositories should implement.type DomainRepository interface { //Loads an aggregate of the given type and ID Load(aggregateTypeName string, aggrega原创 2021-04-08 23:21:58 · 262 阅读 · 0 评论 -
聊聊go.cqrs的AggregateRoot
序本文主要研究一下go.cqrs的AggregateRootAggregateRoot//AggregateRoot is the interface that all aggregates should implementtype AggregateRoot interface { AggregateID() string OriginalVersion() int CurrentVersion() int IncrementVersion() Apply(events EventMes原创 2021-04-07 23:11:29 · 216 阅读 · 0 评论 -
聊聊dkron的Scheduler
序本文主要研究一下dkron的SchedulerScheduler// Scheduler represents a dkron scheduler instance, it stores the cron engine// and the related parameters.type Scheduler struct { Cron *cron.Cron Started bool EntryJobMap sync.Map}// NewScheduler crea原创 2021-04-06 23:12:42 · 232 阅读 · 0 评论 -
聊聊dkron的fsm
序本文主要研究一下dkron的fsmMessageType// MessageType is the type to encode FSM commands.type MessageType uint8const ( // SetJobType is the command used to store a job in the store. SetJobType MessageType = iota // DeleteJobType is the command used to delet原创 2021-04-05 22:55:10 · 173 阅读 · 0 评论 -
聊聊machinery的Lock
序本文主要研究一下machinery的LockLocktype Lock interface { //Acquire the lock with retry //key: the name of the lock, //value: at the nanosecond timestamp that lock needs to be released automatically LockWithRetries(key string, value int64) error //Acquire原创 2021-04-03 23:52:40 · 173 阅读 · 0 评论 -
聊聊machinery的TaskState
序本文主要研究一下machinery的TaskStateTaskStateconst ( // StatePending - initial state of a task StatePending = "PENDING" // StateReceived - when task is received by a worker StateReceived = "RECEIVED" // StateStarted - when the worker starts processing the原创 2021-04-02 23:43:12 · 215 阅读 · 0 评论 -
聊聊go-ddd-sample
序本文主要赏析一下go-ddd-sample项目结构├── _sql├── application├── config├── domain│ └── repository├── infrastructure│ └── persistence│ └── testdata└── interfaces └── testdata这里分为application、domain、infrastructure原创 2021-03-23 00:00:48 · 337 阅读 · 0 评论 -
聊聊golang的clean architecture项目结构
序本文主要研究一下golang的clean architecture项目结构clean architecure[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Q4XGa2Zd-1615644923764)(https://blog.cleancoder.com/uncle-bob/images/2012-08-13-the-clean-architecture/CleanArchitecture.jpg)]clean architecture定义了四层结构,最内层是e原创 2021-03-13 22:15:31 · 399 阅读 · 0 评论 -
聊聊dapr的Pipeline
序本文主要研究一下dapr的PipelinePipelinedapr/pkg/middleware/http/http_pipeline.goimport ( "github.com/dapr/dapr/pkg/config" "github.com/valyala/fasthttp")type Middleware func(h fasthttp.RequestHandler) fasthttp.RequestHandler// HTTPPipeline defines the mi原创 2021-03-10 23:02:57 · 136 阅读 · 0 评论 -
dapr的consistent hash
序本文主要研究一下dapr的consistent hashconsistent_hashdapr/pkg/placement/hashing/consistent_hash.govar replicationFactor int// ErrNoHosts is an error for no hostsvar ErrNoHosts = errors.New("no hosts added")// ConsistentHashTables is a table holding a map o原创 2021-03-09 23:38:08 · 138 阅读 · 0 评论 -
聊聊dapr的fswatcher
序本文主要研究一下dapr的fswatcherfswatcherdapr/pkg/fswatcher/fswatcher.goimport ( "context" "strings" "time" "github.com/fsnotify/fsnotify" "github.com/pkg/errors")func Watch(ctx context.Context, dir string, eventCh chan<- struct{}) error { watcher,原创 2021-03-08 23:22:37 · 151 阅读 · 0 评论 -
聊聊dapr的metrics_utils
序本文主要研究一下dapr的metrics_utilsNewMeasureViewdapr/pkg/diagnostics/utils/metrics_utils.go// NewMeasureView creates opencensus View instance using stats.Measurefunc NewMeasureView(measure stats.Measure, keys []tag.Key, aggregation *view.Aggregation) *view.V原创 2021-03-07 23:40:44 · 258 阅读 · 0 评论 -
聊聊dapr的Limiter
序本文主要研究一下dapr的LimiterLimiterdapr/pkg/concurrency/limiter.goconst ( // DefaultLimit is the default concurrency limit DefaultLimit = 100)// Limiter objecttype Limiter struct { limit int tickets chan int numInProgress int32}Limi原创 2021-03-06 22:10:15 · 135 阅读 · 0 评论 -
聊聊storagetapper的cache
序本文主要研究一下storagetapper的cachecachestoragetapper/pipe/cache.gotype cacheEntry struct { pipe Pipe cfg config.PipeConfig}var cache map[string]cacheEntryvar lock sync.Mutexcache是一个cacheEntry的map,cacheEntry定义了Pipe和config.PipeConfigCacheGetstorag原创 2021-03-04 23:59:18 · 283 阅读 · 1 评论 -
聊聊storagetapper的pool
序本文主要研究一下storagetapper的poolThreadstoragetapper/pool/pool.gotype Thread interface { Start(m uint, f func()) Adjust(m uint) Terminate() bool NumProcs() uint}Thread接口定义了Start、Adjust、Terminate、NumProcs方法poolstoragetapper/pool/pool.go/*Create he原创 2021-03-03 23:57:31 · 143 阅读 · 2 评论 -
聊聊storagetapper的pipe
序本文主要研究一下storagetapper的pipePipestoragetapper/pipe/pipe.gotype Pipe interface { NewConsumer(topic string) (Consumer, error) NewProducer(topic string) (Producer, error) Type() string Config() *config.PipeConfig Close() error}Pipe接口定义了NewConsumer原创 2021-03-02 23:45:24 · 127 阅读 · 0 评论 -
聊聊storagetapper的Lock
序本文主要研究一下storagetapper的LockLockstoragetapper/lock/lock.go/*Lock is general distributed lock interface*/type Lock interface { // Try to acquire a lock. Returns false if failed. TryLock(s string) bool // Try to acquire a lock. Returns false if failed原创 2021-03-01 23:35:40 · 145 阅读 · 0 评论 -
聊聊storagetapper的server
序本文主要研究一下storagetapper的serverserverstoragetapper/server/server.govar server *http.Servervar mutex = sync.Mutex{}func init() { http.HandleFunc("/health", healthCheck) http.HandleFunc("/schema", schemaCmd) http.HandleFunc("/cluster", clusterInfoCmd原创 2021-02-28 23:49:42 · 148 阅读 · 0 评论 -
聊聊nacos-coredns-plugin的UDPServer
序本文主要研究一下nacos-coredns-plugin的UDPServerUDPServernacos-coredns-plugin/nacos/udp_server.gotype UDPServer struct { port int host string vipClient *NacosClient}UDPServer定义了port、host、vipClient属性StartServernacos-coredns-plugin/nacos/udp_server.gof原创 2021-02-27 22:02:11 · 334 阅读 · 0 评论 -
聊聊nacos-coredns-plugin的Domain
序本文主要研究一下nacos-coredns-plugin的DomainDomainnacos-coredns-plugin/nacos/nacos_domain.gotype Domain struct { Name string `json:"dom"` Clusters string CacheMillis int64 LastRefMillis int64 Instances []Instance `json:"hosts"` Env string TTL int}fu原创 2021-02-25 23:35:11 · 363 阅读 · 0 评论 -
聊聊gost的DeltaCompare
序本文主要研究一下gost的DeltaCompareDeltaComparegost/math/compare.go// equivalent to math.Abs(expected - actual) <= deltafunc DeltaCompareFloat64(expected float64, actual float64, delta float64) bool { if expected > actual { return expected-actual <原创 2021-02-24 23:48:35 · 106 阅读 · 0 评论 -
聊聊gost的HashSet
序本文主要研究一下gost的HashSetHashSetgost/container/set/hashset.govar itemExists = struct{}{}type HashSet struct { Items map[interface{}]struct{}}func NewSet(values ...interface{}) *HashSet { set := &HashSet{Items: make(map[interface{}]struct{})} if原创 2021-02-23 23:28:21 · 176 阅读 · 0 评论 -
聊聊gost的CountWatch
序本文主要研究一下gost的CountWatchCountWatchgost/time/count.gotype CountWatch struct { start time.Time}func (w *CountWatch) Start() { var t time.Time if t.Equal(w.start) { w.start = time.Now() }}func (w *CountWatch) Reset() { w.start = time.Now()}原创 2021-02-22 23:27:11 · 152 阅读 · 0 评论 -
聊聊gost的GenericTaskPool
序本文主要研究一下gost的GenericTaskPoolGenericTaskPoolgost/sync/task_pool.go// GenericTaskPool represents an generic task pool.type GenericTaskPool interface { // AddTask wait idle worker add task AddTask(t task) bool // AddTaskAlways add task to queues or d原创 2021-02-21 10:48:27 · 146 阅读 · 0 评论 -
聊聊gost的ObjectPool
序本文主要研究一下gost的ObjectPoolObjectPoolgost/bytes/bytes_buffer_pool.go// Pool is bytes.Buffer Pooltype ObjectPool struct { New New pool sync.Pool}func NewObjectPool(n New) *ObjectPool { return &ObjectPool{New: n}}// take returns *bytes.Buffer原创 2021-02-20 22:18:21 · 125 阅读 · 0 评论 -
聊聊gost的Pager
序本文主要研究一下gost的PagerPagergost/hash/page/pager.go// Pager is the abstraction for pagination usage.type Pager interface { // GetOffset will return the offset GetOffset() int // GetPageSize will return the page size GetPageSize() int // GetTotalPa原创 2021-02-19 23:20:51 · 161 阅读 · 0 评论 -
聊聊gost的GoUnterminated
序本文主要研究一下gost的GoUnterminatedGoUnterminatedgost/runtime/goroutine.go// GoUnterminated is used for which goroutine wanna long live as its process.// @period: sleep time duration after panic to defeat @handle panic so frequently. if it is not positive,/原创 2021-02-18 23:52:00 · 132 阅读 · 1 评论 -
聊聊gost的GoSafely
序本文主要研究一下gost的GoSafelyGoSafelygost/runtime/goroutine.gofunc GoSafely(wg *sync.WaitGroup, ignoreRecover bool, handler func(), catchFunc func(r interface{})) { if wg != nil { wg.Add(1) } go func() { defer func() { //...... }() handler() }(原创 2021-02-17 10:27:40 · 186 阅读 · 0 评论
分享